var Course = {
	examItems: null,
	chapterId: null,
	chname: null,
	knowledgeId: null,
	kname: null,
	evet: null,
	etype:{1:"阶段性作业",2:"结业考试"},
	knowClick:true,
	// 评论id
	replyId: null,
	editInit: function() {
	    $('#myTab a:first').tab('show');
	    $('#myTab a').click(function (e) {
	        e.preventDefault();
	        $(this).tab('show');
	    });
		var id = $.query.get("id");
		$ajax({
			url:"/course/detailCourse",
			data:{
				_id : id
			},
			success: function(res) {
				var items = res.result;
				Course.items = items;
				$("#courseName").data("id", items._id);
				$("#courseName").text(items.name);
				$("#photoBtn").data("url", items.photo);
				$("#courseCtn .feeInput").text(items.fee);
				var chapter = items.chapter;
				var html = "";
				for (var i=0; i<chapter.length; ++i) {
					var icon = "";
					if (chapter[i].knowledge.length)
						icon = "glyphicon-plus";
					html += Course.gnChapter(chapter[i]);
                    html += '<div class="child hidden">';
                    var knowledge = chapter[i].knowledge;
                    for (var j=0; j<knowledge.length; ++j)
						html += Course.gnKnowledge(knowledge[j]);
	                html += '</div>';
				}
				$("#tree").html(html);
				var teacher = items.teachers;
				for (var i=0; i<teacher.length; ++i)
					$("#teacherCtn").append(teacher[i].name+"　");
				$("#courseCtn .desInput").val(items.des);
				$("#courseCtn input[name='fee'][value='"+ items.fee +"']").prop("checked", "checked");
			}
		});
		$("#tree").on("click", ".nodeEvent", function(){
			Course.chapterId = $(this).parent("li").data("item")._id;
			if ($(this).hasClass("glyphicon-plus")) {
				$(this).removeClass("glyphicon-plus").addClass("glyphicon-minus");
				$(this).parent().next().removeClass("hidden");
			} else if ($(this).hasClass("glyphicon-minus")) {
				$(this).removeClass("glyphicon-minus").addClass("glyphicon-plus");
				$(this).parent().next().addClass("hidden");
			}
			return false;
		});
		$("#content").on("click", ".list-group-item.itemEvent", function(){
			if (!$(this).hasClass("selected")) {
				$(".list-group-item.selected").removeClass("selected");
				$(this).addClass("selected");
			}
			return false;
		});
		$("#content").on("click", ".itemEvent", function(){
			Course.knowledgeId = $(this).data("item")._id;
			$("#player").empty();
			var ctn = $(this).data("ctn");
			var item = $(this).data("item");
			$(".markEvent").removeClass("hidden");
			$(".issue").empty();
			if (ctn == "chapterCtn") {
				$("#chapterCtn .desInput").text(item.des);
				$("#chapterCtn .freeInput").text(item.free?"是":"否");
				if (item.ctype == 1) {
					$(".markEvent").addClass("hidden");
					//修改访问地址
					//Course.examInit("http://examapi.netmall.net.cn/exam/GetExamQuestionsByKP?kpname="+ item.extra +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4", $("#chapterCtn .issue"));
					Course.examInit("http://ksapi.lndx.edu.cn/exam/GetExamQuestionsByKP?kpname="+ item.extra +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4", $("#chapterCtn .issue"));
					//显示题目
					// $("#chapterCtn").append(Course.examList(, item.exam, $("#chapterCtn")));
				} else if (item.ctype == 2) {
					$(".markEvent").addClass("hidden");
					//Course.examInit("http://examapi.netmall.net.cn/exam/GetExamQuestionsByKP?kpname="+ $("#courseName").text() +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4&QuestionInfo="+item.extra, $("#chapterCtn .issue"));
					Course.examInit("http://ksapi.lndx.edu.cn/exam/GetExamQuestionByKPAndConditions?kpname="+ $("#courseName").text() +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4&QuestionInfo="+item.extra, $("#chapterCtn .issue"));

				}
			} else if (ctn == "knowledgeCtn") {
				$("#knowledgeCtn .desInput").text(item.des);
				var itemTitle = item.title || "";
				var itemTitleType = itemTitle.split(".")[itemTitle.split(".").length-1];
				if(itemTitleType == "pdf"){
             		$("#player").html('<iframe width="100%" height="466" src="'+Core.API_VER + '/pdf/' + itemTitle+'"> </iframe>');
             		//var success = new PDFObject({ url: Core.API_VER + "/pdf/" + itemTitle }).embed("player");
				}else{ 
					var player = polyvObject('#player').videoPlayer({
					    'width':'100%',
					    'height':'466',
					    'vid' : item.vid,
						'flashParams':{'allowFullScreen':'true','wmode':'transparent'}
					});
				}
				Course.videoCommentInit(item);
				Course.examInit(item.exam, $("#knowledgeCtn .issue"));
			}
			$(".boxCtn").addClass("hidden");
			$("#"+ctn).removeClass("hidden");
			return false;
		});
	},
	plus: function(action) {
		var val = $("#message").val();
		if (val == "")
			return;

		var html = "";
		if (action == "chapter") {
			var item = {ctype:$("input[type='radio'][name='ctype']:checked").val(), des:"", exam:[], free:0, knowledge:[], name:val, range:[]};
			// console.log(item)
			$("#tree").append(Course.gnChapter(item)+'<div class="child hidden"></div>');
		} else if (action == "knowledge") {
			var item = {name:val, url:"", des:"", exam:[]};
            $(".chapterEvent.selected").next().append(Course.gnKnowledge(item));
            var $dom = $(".chapterEvent.selected>.nodeEvent");
            if (!$dom.hasClass("glyphicon-minus"))
            	$dom.addClass("glyphicon-plus");
		}
	},
	gnChapter: function(item) {
		var icon = "";
		if (item.knowledge.length > 0)
			icon = "glyphicon-plus"; 
		var html = '<li data-ctn="chapterCtn" data-item=\''+ JSON.stringify(item) +'\' class="list-group-item itemEvent chapterEvent">'+
	                    '<span class="icon glyphicon '+ icon +' nodeEvent"></span>'+
	                    '<span class="icon glyphicon glyphicon-book"></span><span class="text">'+ item.name +'</span>' +
	                '</li>';
	    return html;
	},
	gnKnowledge: function(item) {
		var html = '<li data-ctn="knowledgeCtn" data-item=\''+ JSON.stringify(item) +'\' class="list-group-item itemEvent knowledgeEvent">'+
		                '<span class="icon glyphicon glyphicon-book"></span><span class="text">'+ item.name +'</span>' +
		            '</li>';
	    return html;
	},
	examInit: function(url, $dom){
		var examFn = function(res, isFinalExam) {
			Course.examItems = res;
			var html = "";
			var number = 0;
			var numbertwo =0;
			var numberthree =0;
			var numberfour =0;
			for (var i = 0; i < res.length; i ++){
				var Tip = '亲，等等~会有的......';
				if(res[i].QuestionType <6){
					if(res[i].Content.indexOf("img") > 0)
						var resconent = res[i].Content.replace(/\n/g,'<br/>');
					else 
						var resconent = '<xmp>'+res[i].Content.replace(/\n/g,'</xmp><br/><xmp>').replace(/&gt;/g,'>').replace(/&lt;/g,'<').replace(/<br \/>/g,'')+'</xmp>';
				}
				if(res[i].hasOwnProperty('Tip'))
					Tip = res[i].Tip;

				if (res[i].QuestionType == EXAMTYPE.SINGLE_CHOICE){//单选
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' +  res[i].QScore + '分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none;">' + resconent + '</div>';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        	var queopt = res[i].QuestionOptionList[j].Content;
                        	if(queopt =='<')
                        		queopt = '&lt';
                        	else if(queopt =='>')
                        		queopt = '&gt';
                        	else if(queopt =='&')
                        		queopt = '&amp';
                        	else if(queopt == ' ')
		                        queopt = queopt.replace(' ', '&nbsp;');
                        	html += '<span>' + 
                                        '<label><input type="radio" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '"><xmp>' + queopt + '</xmp></label>' + 
                                    '</span>';
                        }
                        var trueChoice = "";

                		for (var f = 0; f < res[i].QuestionOptionList.length; f ++){
                        	if (res[i].QuestionOptionList[f].IfRightAnswer == "true"||res[i].QuestionOptionList[f].IfRightAnswer == true){
                        		trueChoice +=  res[i].QuestionOptionList[f].Content + '；';
                        		 
                        	}          		
                        }
                    	html += 	'<div id="right'+ (number+=1) +'" class="daan daan-2 hide tipEvt2" style="padding-left:5em;border-bottom:none;">正确答案：<xmp>'+ trueChoice + '</xmp></div>';
        				html += 	'<div id="error'+ (number) +'" class="daan daan-1 hide tipEvt1" style="padding-left:5em;border-bottom:none;">正确答案：<xmp>'+ trueChoice + '</xmp></div>';
	                    html += 	'<div class="jiexi hide tipEvt">'+
										'<div class="left jiexi-left" style="font-weight: bold;">解析：</div>'+
										'<div class="right jiexi-right"><xmp>' + Tip + '</xmp></div>' + 
	                        		'</div>' +
                        		'</div>' +
                            '</div>';
				}
				else if (res[i].QuestionType == EXAMTYPE.MULTIPLE_CHOICE){//多选
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + 
                               + res[i].QScore + 
                                '分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none">' + resconent + '</div>';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        	html += '<span>' + 
                                        '<label><input type="checkbox" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '"><xmp>' + res[i].QuestionOptionList[j].Content + '</xmp></label>' + 
                                    '</span>';
                        }      
                        //html += '<div class="hide tipEvt" style="padding-left:1em;padding-top:20px;"><font style="font-weight:bold">正确答案：</font>';
                        		var multiple_res ="";
                        		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                        	if (res[i].QuestionOptionList[j].IfRightAnswer == "true"||res[i].QuestionOptionList[j].IfRightAnswer == true){
		                        		multiple_res += res[i].QuestionOptionList[j].Content +"；";
		                        	}          		
		                        }
		                        		html += '<div id="tworight'+ (numbertwo+=1) +'" class="daan daan-2 hide tipEvt4" style="padding-left:5em;border-bottom:none;">正确答案：<xmp>'+ multiple_res + '</xmp></div>';
	            						html += '<div id="twoerror'+ (numbertwo) +'" class="daan daan-1 hide tipEvt3" style="padding-left:5em;border-bottom:none;">正确答案：<xmp>'+ multiple_res + '</xmp></div>';
	            					
		                html += '</div>'
                        html += '<div class="jiexi hide tipEvt">'+
										'<div class="left jiexi-left " style="font-weight: bold; font-size:16px;">解析：</div>'+
										'<div class="right jiexi-right" style="line-height:200%;font-size:16px"><xmp>' + Tip + '</xmp></div>' + 
                        		'</div>' +
                        		'</div>'  
                            '</div>';     
				}
				else if (res[i].QuestionType == EXAMTYPE.JUDGE){//判断
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + 
                                + res[i].QScore + 
                                '分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none">' + resconent + '</div>';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        	html += '<span>' + 
                                        '<label><input type="radio" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
                                    '</span>';
                        }     
                        //html += '<div class="hide tipEvt" style="padding-left:1em;padding-top:20px;"><font style="font-weight:bold">正确答案：</font>';
                        		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                        	if (res[i].QuestionOptionList[j].IfRightAnswer == "true"||res[i].QuestionOptionList[j].IfRightAnswer == true){
		                        		//html += res[i].QuestionOptionList[j].Content ;
		                        		html += 	'<div id="threeright'+ (numberthree+=1) +'" class="daan daan-2 hide tipEvt6" style="padding-left:5em;border-bottom:none;">正确答案：'+res[i].QuestionOptionList[j].Content + '</div>';
	                        			html += 	'<div id="threeerror'+ (numberthree) +'" class="daan daan-1 hide tipEvt5" style="padding-left:5em;border-bottom:none;">正确答案：'+res[i].QuestionOptionList[j].Content + '</div>';
		                        	}          		
		                        } 
                        html += '</div><div class="jiexi hide tipEvt">'+
									'<div class="left jiexi-left" style="font-weight: bold;font-size:16px;">解析：</div>'+
									'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + Tip + '</div>' + 
                        		'</div>' +
                        		'</div>'  
                            '</div>'; 
				}
				else if (res[i].QuestionType == EXAMTYPE.FILL){//填空
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                                + res[i].QScore + 
                                '分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none">' + resconent + '</div>'+
                        			'<label style="padding-left:20px;"><input type="text" style="width:90%;" id="' + res[i].Id + '"></label>';
                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
                        			}
                       	html += '<div class="jiexi hide tipEvt">'+
										'<div class="left jiexi-left" style="font-weight: bold;">解析：</div>'+
										'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + Tip + '</div>' + 
                        		'</div>' +
                        		'</div>' +
                            '</div>';

				}
				else if (res[i].QuestionType == EXAMTYPE.SUBJECTIVE){//问答
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + 
                                + res[i].QScore +'分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none">' + resconent.substring(res[i].Content.indexOf(')')+1) + '</div>' + 
                        			'<label style="padding-left:20px;width:90%"><textarea type="text" id="' + res[i].Id + '"></textarea></label>';
                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
                        			}
                   
		                    html += '<div class="jiexi hide tipEvt">'+
										'<div class="left jiexi-left" style="font-weight: bold;">解析：</div>'+
										'<div class="right jiexi-right" style="line-height:200%;font-size:16px">'+ Tip +'</div>'+
		                        	'</div>'+
                        		'</div>';
	     				
	     				html +=	'<div class="over addCc">'+
								'	<!-- 显示 -->'+
								'	<div class="left ">'+
								'		<div class=" over">'+
				                '            <div class="marR20 left" style="position: relative;">'+
				                 '           	<img src="img/a1.jpg" width="183" height="105">'+
				                 '           	<p class="mingZ bor-siz filedoc" id="fieldD'+(i+1)+'"></p>'+
				                '            </div>'+
				                '			<div class="left">'+
				                '        		<div class="fl photo" id="photoD'+(i+1)+'"></div>'+
				                // '				<img src="img/a1.jpg" width="183" height="105">'+
				                '			</div>'+
				                  '      </div>'+
								'	</div>'+
								'	<!-- 按钮 -->'+
								'	<div class="right">'+
								'		<input type="submit" data-phonum="'+(i+1)+'" class="btnJd fs16 shadowbr2 m-r10 phoup" value="上传图片">'+
								'		<input type="submit" data-filnum="'+(i+1)+'" class="btnJd fs16 shadowbr2 fileup" value="上传文档">'+
								'	</div>'+
								'</div>';

                    html +='</div>';
					
				}
				else if (res[i].QuestionType == EXAMTYPE.LIGATURE){//连线
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + 
                                + res[i].QScore + 
                                '分</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:80%;border-bottom:none;height:14em">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
		                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>' + 
                            '</div>';     
                        html += '<div class="hide tipEvt" style="padding-left:1.3em;">点击下面内容查看正确答案 : </div>' + 
                        		'<ul class="hide tipEvt">' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:80%;border-bottom:none;height:14em">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
		                            		for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
		                            			if (res[i].QuestionOptionList[l].OrderNum == res[i].QuestionOptionList[j].OrderNum+1)
		                            				var ans = res[i].QuestionOptionList[l].Id;
		                            		}
		                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>' +   
                       			'<div class="jiexi hide tipEvt">'+
										'<div class="left jiexi-left " style="font-weight: bold;">解析：</div>'+
										'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + Tip + '</div>' + 
                        		'</div>' +
                        		'</div>'  
                            '</div>';   
				}
				else if (res[i].QuestionType == EXAMTYPE.SORT){//排序
					//冒泡排序,用于正确答案
					var temp = 0;
					var targetArr = res[i].QuestionOptionList;
		            for(var k = 0;k<targetArr.length;k++){
		                for(var j = k;j<targetArr.length;j++){
		                    if(targetArr[k].OrderNum>targetArr[j].OrderNum){
		                        temp = targetArr[k];
		                        targetArr[k] = targetArr[j];
		                        targetArr[j] = temp;
		                     }
		                 }
		            }
					html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + 
                                 + res[i].QScore + 
                                '分</span></div>' + 
                                '<div class="mkyl-box" style="border-bottom:none;font-size:16px;line-height: 30px;">' + res[i].Content + '</div>' + 
                                '<div class="custom_order" id="custom_order">' + 
			                    '    <div class="custom_sort_form">' + 
			                    '        <ul class="sort_div" id="sort_div">';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                        	html += '<li id="' + res[i].QuestionOptionList[j].Id + '" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
	                                '    <div class="v_middle" id="' + res[i].QuestionOptionList[j].Id + '_h" style="cursor: move;">' + res[i].QuestionOptionList[j].Content + '</div>' + 
	                                '</li>';
                        }      
		                    html += '	 </ul>' ;
		                    		//'<div class="hide tipEvt" style="padding-left:1em;padding-top:20px;"><font style="font-weight:bold;font-size:16px">正确答案：</font></div>';
			                		var sortTrue = "";
			                		for (var j = 0; j < targetArr.length; j ++){
			                        sortTrue  += '<li class="hide tipEvt" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;">' + 
				                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
				                                '</li>';
		                        	}
		                        	html += '<div id="fourright'+ (numberfour+=1) +'" class="daan daan-2 hide tipEvt8" style="width:80%;height:480px; padding-left:5em;border-bottom:none;">正确答案：'+ sortTrue +'</div>' ;
									//html += '<div class="daan daan-2 hide tipEvt6" style="padding-left:5em;border-bottom:none;">正确答案：'+res[i].QuestionOptionList[j].Content + '</div>';
            						html += '<div id="fourerror'+ (numberfour) +'" class="daan daan-1 hide tipEvt7" style="width:80%;height:480px;padding-left:5em;border-bottom:none;">正确答案：'+ sortTrue +'</div>' ;

		                    		'<div class="jiexi hide tipEvt" style="border:none">' +'<div class="left jiexi-left" style="font-weight: bold;">解析 : </div>'+'<div class="right jiexi-right" style="line-height:200%;font-size:16px">'+ Tip +'</div></div>';
	                        '</div>' + 
			                    '</div>' + 
			                '</div>';            
				}
			}
			if(res.length >= 1){
				html += '<div class="input_button" style="text-align: right;padding: 1em 2em 1em 0;border-top:1px solid #8aadfd;"><input id="issueCtn" class="right mkyl-sub jyks_sub" type="button" value="提交" ></div>';
			}else{
				html += '<div class="input_button" style="text-align: right;padding: 1em 2em 1em 0;border-top:1px solid #8aadfd;"><input class="right mkyl-sub" style="background-color:#cccccc	" type="button" value="提交" ></div>';
			}
			// console.log(html);
			$dom.html(html);
			if(isFinalExam == 1){
				$(".score").hide();
			}
			// 初始化连线canvas
			var mblBoxs=$(".matchByLineBox");
			mblArr=[];//全局 存储所有mbl实例
			mblBoxs.each(function(x){
				var mbl=new MatchByLine(mblBoxs.eq(x));
				mbl.init();
				mblArr.push(mbl);
			});
			// 初始化拖动排序
			initDrag();
			$("#issueCtn").click(function(){
				Course.issueCtn($(this));
			});
			// 图片上传
			$(".phoup").click(function(){
				var phonum = $(this).data('phonum');
				$(".tan_x").show();
				$('.tan_x').height($(document).height());
				$("#photo").show();
				$("#photoBtn").attr('phonum',phonum);
			});
			$("#photoD").change(function(){
				$("#loadding").removeClass('hidden');
			});
			$("#photoBtn").uploadify({
			    'swf'        : 'js/core/uploadify.swf',
			    'uploader'   :  Core.API_VER+"/upload?compress=0",
			    'buttonText' : '点击上传',
			    'method':"post",
			    'fileTypeDesc': '请选择图片格式', 
			    'fileTypeExts': '*.jpg;*.jpeg;*.png;*.gif;*.swf',
			    'fileSizeLimit'   : '3072',
			    'onUploadSuccess' : function(file, res) {
			        res = eval('(' + res + ')');
			        if (res.code) {
			    		$alert(res.codemsg);
			    		return;
			    	}             
			        var url = res.result.url;	
			    	$("#photoBtn").attr("data-url",url);
			    	var src = Core.id2url(url);
			    	$("#photoD").html('<img style="width:183px;" src="' + src + '">');
			    	$("#photoD"+$("#photoBtn").attr('phonum')).html('<img style="width:183px;" src="' + src + '">');                     
			    	$(".close").click();
			    	$("#loadding").addClass('hidden');
			    },
			    'onUploadStart' : function(file) {
			                         
			    } 
			});
			$(".close").click(function(){
				$("#photoD").val('');
				$(".tan_x,#photo").hide();
				$(".fileName,.data,.cancel").text('');
			});
			// 文档上传
			$(".fileclose").click(function(){
				$("#fileupload").val('');
				$(".tan_x,#pdfFiles").hide();
			});
			//$("#photoBtn").change(Course.upload);
			$(".fileup").click(function(){
				var filnum = $(this).data('filnum');
				$(".tan_x").show();
				$('.tan_x').height($(document).height());
				$("#pdfFiles").show();
				$("#fileupload").attr('filnum',filnum);
			});
			$("#fileupload").change(function() {
				$("#loadding").removeClass('hidden');
				$("#pdfForm").ajaxSubmit({
			        url: Core.API_VER+"/upload?compress=999",
			        type: "post",
			        success: function (res, textStatus) {
			        	//res = JSON.parse(res);
			        	if (res.code) {
			        		if(res.code !=7)
			        			$alert(res.codemsg);
			        		return;
			        	}	        
			        	var url = res.result.url;
			        	var fileType = url.split(".")[url.split(".").length-1];
			        	$(".fileclose").click();
			        	$("#loadding").addClass('hidden');
			        	//console.log(url);
			        	$("#fieldD"+$("#fileupload").attr('filnum')).html(url);
			        	// if(fileType != "pdf")
			        	// 	return alert("上传文件类型有误！");
			        	// changeFn("title", url);
			        },error:function(XMLHttpRequest, textStatus){
						var status = XMLHttpRequest.status;
						if (status == 0)
							return;
						else if (status == 500)
							$alert("服务器错误");
						else
							$alert("请检查您的网络。");
			        }
		    	});
			});
		};
		if (typeof url == "object") {
			examFn(url, 1);
		} else {
			url = encodeURI(url);
			$.ajax({
				url: url,
				type: "get",
				success: function(res){
					examFn(res, 0);
				}
			});
		}
	},
	upload: function(){
		$("#photoForm").ajaxSubmit({
	        url: Core.API_VER+"/upload?compress=0",
	        type: "post",
	        success: function (res, textStatus) {
	        	//res = JSON.parse(res);
	        	if (res.code) {
	        		$alert(res.codemsg);
	        		return;
	        	}	        
	        	var url = res.result.url;	
	        	$("#photoBtn").attr("data-url",url);
	        	var src = Core.id2url(url);
	        	$("#photoD").html('<img style="width:183px;" src="' + src + '">');
	        },error:function(XMLHttpRequest, textStatus){
				var status = XMLHttpRequest.status;
				if (status == 0)
					return;
				else if (status == 500)
					$alert("服务器错误");
				else
					$alert("请检查您的网络。");
	        }
	    });
	},
	issueCtn: function($this){
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有答题权限");
		//var $this = $(event.currentTarget);
		var data = new Object();
		var key = 0;
		var keytwo = 0;
		var keythree = 0;
		var keyfour = 0;
		var Tipone = {};
		var Tiptwo = {};
		var Tipthree = {};
		var Tipfour = {};
		data.isLabour = false;

		data.questions = new Array();
		data.errorSet = new Array();
		var score = 0;
		var nullQuesNum = '';
		$this.parents(".issue").find(".cnt").each(function(i){
			data.questions[i] = new Object();
			data.questions[i] = Course.examItems[$(this).data("num")];
			// data.questions[i].Id = $(this).data("id");
			// data.questions[i].QScore = $(this).children("h3").children(".score").data("score");
			// data.questions[i].QuestionType = $(this).data("questiontype");
			data.questions[i].trueOrFalse = false;
			data.questions[i].cid = Course.items._id;
			var QuestionType = $(this).data("questiontype");
			if (QuestionType == EXAMTYPE.SINGLE_CHOICE){
				var right = '';
				data.questions[i].stuAnswer = new Array();
				data.questions[i].stuAnswer[0] = $(this).find("input[type='radio']:checked").attr("id");
				if ($(this).find("input[type='radio']:checked").data("ifrightanswer")){
					score += data.questions[i].QScore;
					data.questions[i].trueOrFalse = true;
					right = 'right'+(key+=1);
					Tipone[right] = true;
				} else {
					data.errorSet.push(data.questions[i]);
					right = 'error'+(key+=1);
					Tipone[right] = false;
				}
				if ($(this).find("input[type='radio']:checked").length == 0){
					nullQuesNum += ($(this).data("num")+1) + ",";
				}	
			}
			else if (QuestionType == EXAMTYPE.MULTIPLE_CHOICE){
				data.questions[i].stuAnswer = new Array();
				var flag = false;
				var tworight = '';
				$(this).find("input[type='checkbox']").each(function(j){
					if ($(this).data("ifrightanswer") && $(this).prop("checked")){
						flag = true;
					} else if (($(this).data("ifrightanswer") && !$(this).prop("checked"))|| (!$(this).data("ifrightanswer") && $(this).prop("checked"))){
						flag = false;
						return false;
					}
				});
				$(this).find("input[type='checkbox']:checked").each(function(j){
					data.questions[i].stuAnswer[j] = $(this).attr("id");
				});
				if (flag){
					score += data.questions[i].QScore;
					data.questions[i].trueOrFalse = true;
					tworight = 'tworight'+(keytwo+=1);
					Tiptwo[tworight] = true;
				} else {
					data.errorSet.push(data.questions[i]);
					tworight = 'twoerror'+(keytwo+=1);
					Tiptwo[tworight] = false;
				}
				if ($(this).find("input[type='checkbox']:checked").length == 0){
					nullQuesNum += ($(this).data("num")+1) + ",";
				}	
			}
			else if (QuestionType == EXAMTYPE.JUDGE){
				var threeright ="";
				data.questions[i].stuAnswer = new Array();
				data.questions[i].stuAnswer[0] = $(this).find("input[type='radio']:checked").attr("id");
				if ($(this).find("input[type='radio']:checked").data("ifrightanswer")){
					score += data.questions[i].QScore;
					data.questions[i].trueOrFalse = true;
					threeright = 'threeright'+(keythree+=1);
					Tipthree[threeright] = true;
				} else {
					data.errorSet.push(data.questions[i]);
					threeright = 'threeerror'+(keythree+=1);
					Tipthree[threeright] = false;
				}
				if ($(this).find("input[type='radio']:checked").length == 0){
					nullQuesNum += ($(this).data("num")+1) + ",";
				}	
			}
			else if (QuestionType == EXAMTYPE.FILL){
				var $evt = $(this);
				// $(this).find("input[type='hidden']").each(function(j){
				// 	if ($evt.find("input[type='text']").val() == $(this).val()){
				// 		data[i].QuestionOptionId = $(this).attr("id");
				// 		score += data[i].QScore;
				// 		data[i].trueOrFalse = true;
				// 		return false;
				// 	}
				// });
				data.questions[i].stuAnswer = new Array();
				data.questions[i].stuAnswer[0] = $evt.find("input[type='text']").val();
				data.isLabour = true;
				if ($evt.find("input[type='text']").val() == ""){
					nullQuesNum += ($(this).data("num")+1) + ",";
				}
			}
			else if (QuestionType == EXAMTYPE.SUBJECTIVE){
				var $evt = $(this);
				// $(this).find("input[type='hidden']").each(function(j){
				// 	if ($evt.find("textarea").val() == $(this).val()){
				// 		data[i].QuestionOptionId = $(this).attr("id");
				// 		score += data[i].QScore;
				// 		data[i].trueOrFalse = true;
				// 		return false;
				// 	}
				// });
				data.questions[i].stuAnswer = new Array();
				data.questions[i].stuAnswer[0] = $evt.find("textarea").val();
				//console.log($evt.find("img").attr("src"));
				var datanum = Number($evt.attr('data-num'))+1;
				if($("#photoD"+datanum).find(" img").attr("src") !=undefined)
					data.questions[i].photo = $("#photoD"+datanum).find(" img").attr("src").substring(8);
				if($("#fieldD"+datanum).text() !=undefined && $("#fieldD"+datanum).text() !='')
					data.questions[i].doc = $("#fieldD"+datanum).text();
				data.isLabour = true;
				if ($evt.find("textarea").val() == "" && data.questions[i].photo ==undefined && data.questions[i].doc == undefined){
					nullQuesNum += ($(this).data("num")+1) + ",";
				}
			}
			else if (QuestionType == EXAMTYPE.LIGATURE){
				var $evt = $(this);
				var flag = false;
				var nullFlag = false;
				$(this).find(".matchSideQue .matchOne").each(function(j){
					if ($(this).data("ordernum") == ($("#" + $(this).attr("ans")).data("ordernum") - 1)){
						flag = true;
					}else{
						flag = false;
						return false;
					}
				});
				data.questions[i].stuAnswer = new Array();
				$(this).find(".matchSideQue .matchOne").each(function(j){
					if ($(this).attr("ans"))
						nullFlag = true;
					data.questions[i].stuAnswer[2*j] = $(this).attr("id");
					data.questions[i].stuAnswer[2*j + 1] = $(this).attr("ans");
				});
				if (flag){
					score += data.questions[i].QScore;
					data.questions[i].trueOrFalse = true;
				} else 
					data.errorSet.push(data.questions[i]);
				if (!nullFlag)
					nullQuesNum += ($(this).data("num")+1) + ",";
			}
			else if (QuestionType == EXAMTYPE.SORT){
				var $evt = $(this);
				var flag = false;
				$(this).find(".sort_div li").each(function(j){
					if ($(this).next("li").length != 0){
						if ($(this).data("ordernum") == ($(this).next(".drag_li").data("ordernum") - 1)){
							flag = true;
						}else{
							flag = false;
							return false;
						}
					}	
				});
				data.questions[i].stuAnswer = new Array();
				$(this).find(".sort_div li").each(function(j){
					data.questions[i].stuAnswer[j] = $(this).attr("id");
				});
				
				if (flag){
					score += data.questions[i].QScore;
					data.questions[i].trueOrFalse = true;
					fourright = 'fourright'+(keyfour+=1);
					Tipfour[fourright] = false;
				} else {
					data.errorSet.push(data.questions[i]);
					fourright = 'fourerror'+(keyfour+=1);
					Tipfour[fourright] = false;
				}
			}
		});
		
		if (nullQuesNum){
		//if (false){
			//alert("您还有" + nullQuesNum + "号试题没有完成，继续完成它吧!");
			//alert("1");	
			var tan = '<div class="tan_x" ></div>'+
			           ' <div id="tan_all" style="width:500px; min-height:240px;height:auto;left:44%;top:50%;border-radius:10px; ">'+
			           '     <div  style="display:block;">'+
			           '         <form name="loginform" action="" method="">'+
			           '            <div class="tan-poptit" >'+
			           '               <div class="queRen c" style="word-break:break-all;line-height: 30px;padding-top:10px">您还有' + nullQuesNum + '号试题没有完成，继续完成它吧!</div>'+
			           '                 <div class="t_btn_2">'    +
			           '                   <span id="cancel" class="bg_green">确定</span>'+
			           // '                   <input class="t_sub bg_blue" type="submit" value="确定">'+
			           '               </div>'+
			           '           </div>'+
			           '         </form>'+
			           '    </div>'+
			           '</div>';
			$("#tianC").html(tan);
				
			
			function show_(){
			    $("body,html").animate({scrollTop:0},0);
			    $('.tan_x').show();
			    $('.tan_x').height($(document).height());
			    $('#tan_all').slideDown(200);
			}
			function close_(){
				$('.tan-poptit .close,#cancel').click(function(){
			    $('.tan_x').hide();
			    $('#tan_all').slideUp(200);
				})	
			}
			show_();
			close_();  
			return;
		}
		data.score = score;
		data.student = CurrentUser._id;
		var pro = $.query.get('pro');
		if (window.location.href.indexOf("a_s_")>0){
			data.courseId = Course.items._id;
			data.courseName = Course.items.name;
			if (GetLS("isChaper") == "true"){
				var item = GetLS("currentItem");	
				data.homeworkId = item._id;
				data.chapter = item.extra;
				data.etype = item.ctype;
				data.status = 1;
				if (data.etype == 1){
					var studyData = {};
					studyData.cid = Course.items._id;
					studyData.chid = Course.chapterId;
					studyData.kid = Course.knowledgeId;
					studyData.field = "homework";
					$ajax({
						url:"/course/study",
						data:studyData,
						success: function(res){
						}
					});	
				}
			} else {//每课一练  提交
				var updata = true;
				if(pro == 0 || pro == '0'){//非学历 课程
					majOrNot(updata);
				}else if(pro == 1 || pro == '1'){//学历 课程 
					if(data.errorSet.length == 0){
						majOrNot(updata);
					}else{
						updata = false;
						majOrNot(updata);
					}
				}
				function majOrNot(updata){
					var studyData = {};
					if(updata){//非学历课程 默认上传， 学历课程时：当全部试题正确时调用；
						studyData.cid = Course.items._id;
						studyData.chid = Course.chapterId;
						studyData.kid = Course.knowledgeId;
						studyData.field = "practice";
						$ajax({
							url:"/course/study",
							data:studyData,
							success: function(res){}
						});
					}
					$ajax({
						url: '/examine/savePractice',
						data: {
							student: CurrentUser._id,//学员ID
							courseId: Course.items._id,
							courseName: $('.cont-title').text(),
							homeworkId: Course.chapterId,
							knowledgeId: Course.knowledgeId,
							questions: data.questions
						},
						success: function(res){
							var tan_1 = '<div class="tan_x" ></div>'+
							           	'<div id="tan_all" style="width:500px; height:240px;left:44%;top:50%;border-radius:10px; ">'+
							           	'   <div style="display:block;">'+
							           	'     	<div class="tan-poptit" >'+
							           	'           <div class="queRen c">答题完成！是否需要查看解析？</div>'+
							           	'           <div class="t_btn_2">'    +
							           	'               <span id="cancel" class="bg_green">取消</span>'+
							           	'               <input id="btn_t" class="t_sub bg_blue" type="submit" value="确定">'+
							           	'           </div>'+
							           	'       </div>'+
							           	'   </div>'+
							           	'</div>';
							$("#tianC").html(tan_1);
							function show_1(){
							    $("body,html").animate({scrollTop:0},0);
							    $('.tan_x').show();
							    $('.tan_x').height($(document).height());
							    $('#tan_all').slideDown(200);
							}
							function close_1(){
								$('.tan-poptit .close,#cancel').click(function(){
								    $('.tan_x').hide();
								    $('#tan_all').slideUp(200);
								    return;
								});
							}
							show_1();
							close_1();  
							
							$("#btn_t").click(function(){
								$('.tan_x').hide();
								$('#tan_all').slideUp(200);
								
								$(".tipEvt").removeClass("hide");
								$(".input_button").addClass("hide");
								for(var mkey in Tipone){
										$("#"+mkey).removeClass("hide");
								}
								for(var nkey in Tiptwo){
										$("#"+nkey).removeClass("hide");
								}
								for(var mkey in Tipthree){
										$("#"+mkey).removeClass("hide");
								}
								for(var lkey in Tipfour){
										$("#"+lkey).removeClass("hide");
								}
							});
							return;
						}
					})
				}
				return;
				
			}
		} else {
			data.courseId = $("#courseName").data("id");
			data.courseName = $("#courseName").text();
			if ($(".chapterEvent.selected").length > 0) {
				var item = $(".chapterEvent.selected").data('item');
				data.homeworkId = item._id;
				data.chapter = item.extra;
				data.etype = item.ctype;
				data.status = 1;
			} else {
				var studyData = {};
				studyData.cid = Course.items._id;
				studyData.chid = $(".knowledgeEvent.selected").parent().prev().data("item")._id;
				studyData.kid = $(".knowledgeEvent.selected").data('item')._id;
				studyData.field = "practice";
				$ajax({
					url:"/course/study",
					data:studyData,
					success: function(res){}
				});
				alert("这次练习的分数为："+data.score);
				// "practice"  "video"  "homework"
				return;
			}
		}	
		// console.log(item)
		// console.log(item.ctype);
		// return;
		if (item.ctype == 1){
			var tan_2 = '<div class="tan_x" ></div>'+
				           ' <div id="tan_all" style="width:500px; height:240px;left:44%;top:50%;border-radius:10px; ">'+
				           '     <div  style="display:block;">'+
				           '            <div class="tan-poptit" >'+
				           '               <div class="queRen c">答题完成！是否需要查看解析？</div>'+
				           '                 <div class="t_btn_2">'    +
				           '                   <span id="cancel" class="bg_green">取消</span>'+
				           '                   <input id="btn_t" class="t_sub bg_blue" type="submit" value="确定">'+
				           '               </div>'+
				           '           </div>'+
				           '    </div>'+
				           '</div>';
				$("#tianC").html(tan_2);
				function show_2(){
				    $("body,html").animate({scrollTop:0},0);
				    $('.tan_x').show();
				    $('.tan_x').height($(document).height());
				    $('#tan_all').slideDown(200);
				}
				function close_2(){
						$('.tan-poptit .close,#cancel').click(function(){
					    $('.tan_x').hide();
					    $('#tan_all').slideUp(200);
					    return;
					})	
				}
				show_2();
				close_2();  
				
				$("#btn_t").click(function(){
					$('.tan_x').hide();
					$('#tan_all').slideUp(200);
					
					console.log(CurrentUser);
					$ajax({
						url: '/grade/findStudentGrade',
						data: {
							studentId: CurrentUser._id,
							courseId: Course.items._id
						},
						success: function(res){
							data.gradeId = res.result._id ;//'5652a0011cd582f82be9a0d6';班级test ID 用于测试
							data.gradeName = res.result.name;//'班级test';
							$ajax({
								url:"/examine/saveExamine",
								data:data,
								success:function(res) {
									var title=$(".cont-zj").text().indexOf("考试");
									var tiltb=(title==-1)?false:true;

									var tan = '<div class="tan_x" ></div>'+
								           ' <div id="tan_all" style="width:500px; height:240px;left:44%;top:50%;border-radius:10px; ">'+
								           '     <div  style="display:block;">'+
								           '         <form name="loginform" action="" method="">'+
								           '            <div class="tan-poptit" >'+
								           '               <div class="queRen c" style="word-break:break-all;line-height: 30px;padding-top:10px">完成答题</div>'+
								           '                 <div class="t_btn_2">'    +
								           '                   <span id="cancel1" class="bg_green">确定</span>'+
								           // '                   <input class="t_sub bg_blue" type="submit" value="确定">'+
								           '               </div>'+
								           '           </div>'+
								           '         </form>'+
								           '    </div>'+
								           '</div>';	
										function show_1(){
										    $("body,html").animate({scrollTop:0},0);
										    $('.tan_x').show();
										    $('.tan_x').height($(document).height());
										    $('#tan_all').slideDown(200);
										}
										function close_1(){
											$('.tan-poptit .close,#cancel1').click(function(){
										    $('.tan_x').hide();
										    $('#tan_all').slideUp(200);
										    return;
											})	
										}
									 

									if(data.isLabour&&tiltb){
										// console.log(tiltb);
										//alert("完成答题");
										$("#tianC").html(tan);
										show_1();
										close_1(); 

									$("#cancel1").click(function(){
										//window.location.href = "a_examinationRecords.html?id=" + $.query.get('id');
										window.location.href = "a_indexStudy.html?" + random() + "#myCourseList";
									});
										
									}else if(tiltb){
										$("#tianC").html(tan);
										$(".queRen").text("本次考试的最终成绩为："+data.score+" 分。");
										show_1();
										close_1(); 
										$("#cancel1").click(function(){
											window.location.href = "a_examinationRecords.html?id=" + $.query.get('id')+"&pro="+$.query.get('pro');
										});
									}

									$(".input_button").addClass("hide");
									$(".tipEvt").removeClass("hide");
									for(var mkey in Tipone){
											$("#"+mkey).removeClass("hide");
									}
									for(var nkey in Tiptwo){
											$("#"+nkey).removeClass("hide");
									}
									for(var mkey in Tipthree){
											$("#"+mkey).removeClass("hide");
									}
									for(var lkey in Tipfour){
											$("#"+lkey).removeClass("hide");
									}
									return;
								}
							});
						}
					});
					
				});
			
		}
		
	},
	videoCommentInit: function(item){
		//console.log(item);
		if (CurrentUser.utype == UTYPE.TUTOR)
			$("#quesCreate").css("display","none");
		$ajax({
			url: "/comment/list",
			data: {
				kid: item._id
			},
			success: function(res){
				var data = res.result.results;
				var html = "";
				for (var i = 0; i < data.length;i ++){
					html += Course.gnCommentContent(data[i]._id,data[i].content,data[i].ownerName,data[i].create,"true");
				}
				$("#newsList").html(html);
			}
		});
		$ajax({
			url: "/message/newmsg",
			data: {
				cid : Course.items._id,
				clname: CurrentUser.Class,
				knowledge: item._id
			},
			success: function(res){
				var data = res.result;
				var html = "";
				var hui = "";
				// if (CurrentUser.utype == UTYPE.TUTOR)
				// 	hui = "1";
				for (var i = 0; i < data.length; i ++){
					html += Course.gnCommentContent(data[i].id,data[i].content,data[i].fromName,data[i].create,hui);
				}
				$("#quesList").html(html);
				// $(".a-reply").click(function(){
				// 	var id = $(this).data("id");
				// 	Course.evet = $(this).parents(".newSing");
				// 	showCover('提示信息','请回复您的消息',id,'','Course.replyMess();');
				// 	// Course.replyMess(id);
				// });
				// $(".newSing").click(function(){
				// 	var to = $(this).data("id");
				// 	var knowledge = data[0].knowledge;
				// 	var cid = Course.items._id;
				// 	var clname = CurrentUser.Class;
				// 	var chid = Course.chapterId;
				// 	window.location.href = "a_message.html?to=" + to + "&knowledge=" + knowledge + "&cid=" + cid + "&clname=" + clname + "&chid=" + chid;
				// });
			}
		});
		var tutors = "";
		for (var i = 0; i < Course.items.tutors.length; i ++){
			var checked = "";
			if(i == 0)
				checked = "checked";
			tutors +=  	'<li style="padding:3px 0;"> ' + 
	                        '    <span style="margin-right:5px;"><input type="radio" ' + checked + ' name="teaName" data-to="' + Course.items.tutors[i]._id + '"></span>' + 
	                        '    <span>' + Course.items.tutors[i].name + '</span>' + 
	                        '</li> ';
		}
		$("#sendlist").html(tutors);
	},
	gnCommentContent: function(id,content,ownerName,create,answer){
		// 辅导老师删除
		// var answerHtml = '';
		// if (CurrentUser.utype == UTYPE.TUTOR&&answer)
			// answerHtml = '<a class="a-reply" data-id="'+id+'" style="margin-left: 10px;padding: 1px 3px;" onclick="Course.deleteComment();">删除</a>';
		// end
		// var html =  '<li class="newSing" data-id="' + id + '"  style="cursor:pointer;">' + 
		 //            '    <pre class="q-content">' + content + '<a style="float:right;">' + '</a></pre>' +  
		 //            '    <div class="c-header" style="padding: 5px;">' +  
		 //            '        <a href="" style="margin-left: 5px;"></a>' +  
		 //            '        <span class="q-act">' +  
		 //            '            <span class="q-cmtdate">'  + ownerName + " " + (new Date(create)).pattern("yyyy-MM-dd") + '</span>' +  
		 //             answerHtml + 
		 //            '        </span>' +  
		 //            '    </div>' +   
		 //            '</li>';
	    var html =  '<div class="daP-pl">'+
					'	<div class="daP-img fl"><img src="'+answer+'"><p>'+ ownerName +'</p></div>'+
					'	<div class="daP-intro fr">'+
					'		<p class="fs14" style="min-height:75px;">'+ content +'</p>'+
					'		<p class="c9" align="right"> ' + (new Date(create)).pattern("yyyy-MM-dd") +'</p>'+
					'	</div>'+
					'</div>';


	    return html;            
	},
	// 公开课评论
	stuVideoCommentInitFree: function(item){
		if (CurrentUser.utype == UTYPE.TUTOR){
			$("#quesCreate").css("display","none");
		}
		$ajax({
			url: "/comment/listReply",
			data: {
				knowledgeId: item._id
			},
			success: function(res){
				var data = res.result;
				var html = "";
				var subreply = "";
				var num = data.length+1;


				for (var i = 0; i < data.length;i ++){
					var photo = 'upload/' + data[i].ownerPhoto;    
					if(!data[i].ownerPhoto){
						photo = 'img/teacher.jpg';
					}
					num--;
					if(num === 1){
						subreply = "沙发";
					}else{
						subreply = "第"+num+"楼";
					}
					if(!data[i].ownerName){
						data[i].ownerName = "匿名评价";
					}
					
					// html += Course.gnCommentContentFree(data[i]._id,data[i].content,data[i].ownerName,data[i].create,photo,num);
				   html +=  '<div class="daP-pl">'+
							'	<div class="daP-img fl"><img src="'+photo+'"><p>'+ data[i].ownerName +'</p></div>'+
							'	<div class="daP-intro fr">'+
							'		<p class="fs14" style="min-height:75px;">'+ data[i].content +'</p>'+
							'		<p class="c9" align="right"><span class="mar20">'+subreply+'</span><span class="mar20">' + (new Date(data[i].create)).pattern("yyyy-MM-dd") +'</span> <span class="cred reply" data-reply="'+data[i]._id+'" data-i="'+i+'">回复</span></p>'+
							'		<div class="wrap-hf wrap-reply-'+i+'"><div class="pla"></div>';

							for(var j=0 ; j< data[i].replys.length;j++){
								html += '<div class="huifu">'+
										'	<p class="over "><span class="fl c75 fs14">'+data[i].replys[j].ownerName+'</span><span class="fr c9 ">'+(new Date(data[i].replys[j].create)).pattern("yyyy-MM-dd")+'</span></p>'+
										'	<p class="fs14">'+data[i].replys[j].content+'</p>'+
										'</div>';
							}

				   html +=	'		</div>'+
						 	'	</div>'+
							'</div>';
					
				}
				$("#newsList").html(html);
				
				// 点击回复
				$(".reply").on("click",function(){
					var _id = $(this).data("reply");
					var _i = $(this).data("i");
					// return console.log(_i);
					Course.replyId = _id;
					var $shuru = $(this).parent().next().find(".pla");

					var htm =' <div class="shuru over "> '+
							 '	  	<input class="ipt fl huifutext-'+_i+'" type="text">'+
							 '		<button class="btn fl btnfasong" data-replyId="">发表</button>'+
							 '</div>'
					
					if($shuru.find("div").is(".shuru")){
						if($shuru.is(":hidden")){
							$shuru.fadeIn();
						}else{
							$shuru.fadeOut();
						}
					}else{
						$shuru.prepend(htm);
					}

					$(".wrap-reply-"+_i).delegate('.btnfasong', 'click', function() {
						Course.commentSendFreeSub(_i);
					});
				
				});
				// end
			}
		});
	},
	//主评论
	commentSendFree: function(){
		// return console.log(CurrentUser);
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有评论权限");
		if($("#commentContent").val().length == 0)
			return alert("评论不能为空，请输入评论");
		var data = new Object();
		
		data.content = $("#commentContent").val();
		data.cid = Course.items._id;
		data.chid = Course.chapterId;
		data.kid = Course.knowledgeId;

		data.ownerName = CurrentUser.name;
		data.ownerPhoto = CurrentUser.photo;
		data.ownerEmail = CurrentUser.email;
		// return console.log(data);
		$ajax({
			url: "/comment/upsert",
			data: data,
			success: function(res){
				//ClearLS("plAnddy");
				var photo = 'upload/' + CurrentUser.photo;    
				if(!CurrentUser.photo){
					photo = 'img/teacher.jpg';
				}
				$("#newsList").prepend(Course.gnCommentContentFree(res.result._id,res.result.content,CurrentUser.name,res.result.create,photo));
				$("#commentContent").val("");
				$("#numtext").text("0/200");
			}
		});
	},	
	gnCommentContentFree: function(id,content,ownerName,create,answer,num){
		// console.log(i);
	    var html =  '<div class="daP-pl">'+
					'	<div class="daP-img fl"><img src="'+answer+'"><p>'+ ownerName +'</p></div>'+
					'	<div class="daP-intro fr">'+
					'		<p class="fs14" style="min-height:75px;">'+ content +'</p>'+
					// '		<p class="c9" align="right"> ' + (new Date(create)).pattern("yyyy-MM-dd") +'</p>'+
					'		<p class="c9" align="right"><span class="mar20">最新评论</span><span class="mar20">' + (new Date(create)).pattern("yyyy-MM-dd") +'</span> </p>'+
					'		<div class="wrap-hf">'+
					'			<div class="shuru over hide"> '+
					'				<input class="ipt fl huifutext" type="text">'+
					'				<button class="btn fl btnfasong">发表</button>'+
					'			</div>'+			
					'		</div>'+
					'	</div>'+
					'</div>';
	    return html;  
	},
	//子集评论
	commentSendFreeSub: function(_i){
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有评论权限");
		if($(".huifutext-"+_i).val().length == 0)
			return alert("评论不能为空，请输入评论");
		var data = new Object();
		
		data.content = $(".huifutext-"+_i).val();
		data.cid = Course.items._id;
		data.chid = Course.chapterId;
		data.kid = Course.knowledgeId;

		data.replyId = Course.replyId
		data.ownerName = CurrentUser.name;
	    console.log(data);
		
		// return console.log(data);
		$ajax({
			url: "/comment/upsert",
			data: data,
			success: function(res){
				//ClearLS("plAnddy");
				// console.log(CurrentUser);
				var res = res.result;
				var photo = 'upload/' + CurrentUser.photo;    
				if(!CurrentUser.photo){
					photo = 'img/teacher.jpg';
				}

				$(".wrap-reply-"+_i).append(Course.gnCommentContentFreeSub(res.content,res.create,res.ownerName));
				$(".huifutext"+_i).val("");
				$(".shuru").remove();
			}
		});
	},
	gnCommentContentFreeSub: function(content,create,ownerName){
		// console.log(i);
	    var html =      '<div class="huifu">'+
						'	<p class="over "><span class="fl c75 fs14">'+ownerName+'</span><span class="fr c9 ">'+(new Date(create)).pattern("yyyy-MM-dd")+'</span></p>'+
						'	<p class="fs14">'+content+'</p>'+
						'</div>';
	    return html;       
	},
	// end 2016年1月21日14:28:13
	deleteComment: function(){
		var $this = $(event.currentTarget);
		$ajax({
			url: "/comment/remove",
			data:{
				_id: $this.attr("data-id")
			},
			success: function(res){
				alert("删除成功");
				$this.parent().parent().parent("li").remove();
			}
		});
	},
	gnReplayContent: function(content,create){
		var html =  '<fieldset class="item-form" style="width:90%;">' +  
                    '    <legend style="color: #888;border:none;width:auto;font-size:1em;margin:0;">我的回复:</legend>' +  
                    '    <blockquote style="padding:0 0.5em;margin:0;font-size:1em;">' + content + '</blockquote>' +  
                    '	 <span class="" style="float:right;font-size:0.7em;">' + (new Date(create)).pattern("yyyy-MM-dd HH:mm:ss") + '</span>' + 
                    '</fieldset>'; 
        return html;            
	},
	commentSend: function(){
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有评论权限");
		if($("#commentContent").val().length == 0)
			return alert("评论不能为空，请输入评论");
		var data = new Object();
		data.content = $("#commentContent").val();
		data.cid = Course.items._id;
		data.chid = Course.chapterId;
		data.kid = Course.knowledgeId;
		data.cname = Course.cname;
		data.chname = Course.chname;
		data.kname = Course.kname;
		data.ownerName = CurrentUser.name;
		data.ownerEmail = CurrentUser.email;
		data.ownerPhoto = CurrentUser.photo;

		$ajax({
			url: '/grade/findStudentGrade',
			data: {
				studentId: CurrentUser._id,
				courseId: Course.items._id
			},
			success: function(res){
				//ClearLS("plAnddy");
				console.log(CurrentUser);
				var photo = 'upload/' + CurrentUser.photo;    
				if(CurrentUser.photo == undefined){
					photo = 'img/teacher.jpg';
				}
				data.gradeId = res.result._id ;//'5652a0011cd582f82be9a0d6';班级test ID 用于测试
				data.gradeName = res.result.name;//'班级test';
				$ajax({
					url: "/comment/upsert",
					data: data,
					success: function(res){
						//ClearLS("plAnddy");
						var photo = 'upload/' + CurrentUser.photo;    
						if(CurrentUser.photo == undefined){
							photo = 'img/teacher.jpg';
						}
						$("#newsList").prepend(Course.gnCommentContent(res.result._id,res.result.content,CurrentUser.name,res.result.create,"ture"));
						$("#commentContent").val("");
						$("#numtext").text("0/200");
					}
				});
			}
		});
	},	
	// 获取接口
	// end
	messageSend: function(){
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有提问题的权限");
		var data = new Object();
		data.content = $("#messContent").val();
		data.media = 0;
		data.cid = Course.items._id,
		data.clname = CurrentUser.Class,
		data.chid = Course.chapterId;
		data.knowledge = Course.knowledgeId;
		data.type = 0;
		data.to = $("#sendlist").find("input[name='teaName']:checked").data("to");

		$ajax({
			url: "/message/add",
			data: data,
			success: function(res){
				$("#quesList").html(Course.gnCommentContent(res.result._id,res.result.content,'',res.result.create));
				$("#messContent").val("");
				$("#messnumtext").text("0/200");
				$(".newSing").click(function(){
					var to = res.result.to;
					var knowledge = res.result.knowledge;
					var cid = res.result.cid;
					// var clname = CurrentUser.Class;
					var clname = "";
					var chid = res.result.chid;
					window.location.href = "a_message.html?to=" + to + "&knowledge=" + knowledge + "&cid=" + cid + "&clname=" + clname + "&chid=" + chid;
				});
			}
		});
	},
	replyMess: function(){
		var data = new Object();
		data.content = $("#message").val();
		data.media = 0;
		data.knowledge = Course.knowledgeId;
		data.type = 0;
		data.to = $("#message").data("id");

		$ajax({
			url: "/message/add",
			data: data,
			success: function(res){
				Course.evet.append(Course.gnReplayContent(res.result.content,res.result.create));
			}
		});
	},
	messageInit: function(){
		var data = new Object();
		data.to = $.query.get("to");
		data.knowledge = $.query.get("knowledge");
		data.cid = $.query.get("cid");
		data.clname = $.query.get("clname");

		$ajax({
			url: "/message/list",
			data: data,
			success: function(res){
				var data = res.result;
				var html = "";
				
				for(var i = 0; i < data.length; i ++){
					$("#fromName").text(data[i].toName);
					var a = "float_l";
					var b = "";
					var c = "float_l";
					var bg ="";
					var bg_1="a_ke";
					// var d = Id2url(data[i].fromUrl,"photo");
					var d = data[i].fromName;
					var f =  data[i].chname +" _ "+ data[i].kname/*+" _ "+data[i].cname*/;
					if (CurrentUser._id == data[i].from){
						a = "fr float_r"; 
						b = "right";
						c = "float_r"
					    bg ="bg"
					    bg_1="";
						// d = Id2url(CurrentUser);
						d = data[i].fromName;
						f = "";
					} 

					// else {
					// 	if ($("#fromName").text() == '')
					// 		$("#fromName").text(data[i].toName);
					// }	
					html += '<div class="clearb">' + 
                            '    <div class="' + c + '" style="min-width:120px; padding:0 1.5%;height: 80px;line-height:80px"><span>"' + d + '"</span></div>' + 
                            '    <div class="demo clearfix ' + a +'" style="width:85%;">' + 
                            // '        <div class="tx-c">' + (new Date(data[i].create)).pattern("yyyy-MM-dd HH:mm:ss") + '</div>' + 
                            // '        <span class="triangle ' + b + '"></span>' + 
                            '        <div class="article '+ bg +'">' + data[i].content + '</div>' + 
                            '		 <div style="clear:both;text-align:center"><span class="'+ a +'" style="padding:10px 0 0 0;font-size:12px;color:#999999"> '+ (new Date(data[i].create)).pattern("yyyy-MM-dd") +'</span></div>'+
                           	'        <div style="clear:both;"></div>'+
                            '		 <div class="'+bg_1+'"><span>'+ f + '</span></div>'+
                            '    </div>' + 
                            '</div>';
				}
				$("#messList").html(html);
				var obj = document.getElementById("messList"); 
				obj.scrollTop=obj.scrollHeight; 

			}

		});
	},
	messageAdd: function(){
		var data = new Object();
		data.content = $("#messCon").text();
		data.media = 0;
		data.cid = $.query.get("cid");
		data.clname = $.query.get("clname");
		data.knowledge = $.query.get("knowledge");
		data.type = 0;
		data.to = $.query.get("to");
		 if($("#messCon").text().length == 0)
		 return alert("请添加回复内容");
		 // alert($("#messCon").text().length)
		
		$ajax({
			url: "/message/add",
			data: data,
			success: function(res){
				

				var html  = '<div class="clearb">' + 
                            '    <div class="float_r" style="min-width:120px; padding:0 1.5%;height: 80px;line-height:80px"><span>"' + CurrentUser.name + '"</span></div>' + 
                            '    <div class="demo clearfix fr float_r" style="width:85%;">' + 
                            // '        <div class="tx-c">' + (new Date(res.result.create)).pattern("yyyy-MM-dd HH:mm:ss") + '</div>' + 
                            // '        <span class="triangle right"></span>' + 
                            '        <div class="article bg">' + res.result.content + '</div>' + 
                            '		 <div style="clear:both;text-align:center"><span>'+(new Date(res.result.create)).pattern("yyyy-MM-dd HH:mm:ss") +'</span></div>'+
                            '    </div>' + 
                            '</div>';
				$("#messCon").text("");
				$("#messList").append(html);
				var obj = document.getElementById("messList"); 
				obj.scrollTop=obj.scrollHeight;
			}
		});
	},
	turtorMessInit: function(){
		$ajax({
			url: "/message/stuMsgStatusList",
			data: {
				id:CurrentUser._id,
				utype:UTYPE.TUTOR
			},
			success: function(res){
				var data = res.result;
				var hui = "";
				var html = "";
				// for (var i = 0; i < data.length; i ++){
					// html += '<li class="newSing" data-id="' + data[i].id + '" data-knowledge="' + data[i].knowledge + '" data-cid="' + data[i].cid + '" data-chid="' + data[i].chid + '" style="cursor:pointer;">' + 
			  //               '    <pre class="q-content">' + data[i].content + '<a style="float:right;">' + data[i].fromName + '</a></pre>' +  
			  //               '    <div class="c-header" style="padding: 5px;">' +  
			  //               '        <a href="" style="margin-left: 5px;"></a>' +  
			  //               '        <span class="q-act">' +  
			  //               '            <span class="q-cmtdate">' + (new Date(data[i].create)).pattern("yyyy-MM-dd HH:mm:ss") + '</span>' +  
			  //               '        </span>' +  
			  //               '    </div>' +   
			  //               '</li>';
			  
			   html += '<table style="text-align:center" class="table table-bordered">'+
					  '<thead>'+
					   ' <tr>'+
					  '    <th style="text-align:center">学员姓名</th>'+
					  '    <th style="text-align:center">班级（订单）名称</th>'+
					  '   <th style="text-align:center">提交时间</th>'+
					  '   <th style="text-align:center">状态</th>'+
					  '   <th style="text-align:center">操作</th>'+
					  '  </tr>'+
					  '</thead>'+
					  '<tbody>';
			 

				for(var k in data){
			
					if(data[k].status != "")
					{
						
						if(data[k].status == "暂未回答"){
						html +=    ' <tr data-pos="0">'+
								   '   <td>'+data[k].name+'</td>'+
								    '  <td>'+data[k].orderName+'</td>'+
									'  <td>'+data[k].create.substr(0,10)+'</td>'+
									'  <td>'+data[k].status+'</td>'+
								    '  <td><button data-id="' + data[k].id + '" data-knowledge="' + data[k].knowledge + '" data-cid="' + data[k].cid + '" data-chid="' + data[k].chid + '" style="cursor:pointer;"  class="btn btn-success btn-sm showBtn dl-bg">查看详情</button></td>'+
								   ' </tr>';
								   //alert(data[k].status);
						}
					}
					
				} 
				 for(var k in data){
			
					if(data[k].status != "")
					{
						var _time =[];
						if(data[k].status == "已回答"){
						html +=    ' <tr data-pos="0">'+
								   '   <td>'+data[k].name+'</td>'+
								    '  <td>'+data[k].orderName+'</td>'+
									'  <td>'+data[k].create.substr(0,10)+'</td>'+
									'  <td>'+data[k].status+'</td>'+
								    '  <td><button data-id="' + data[k].id + '" data-knowledge="' + data[k].knowledge + '" data-cid="' + data[k].cid + '" data-chid="' + data[k].chid + '" style="cursor:pointer;"  class="btn btn-success btn-sm showBtn dl-bg">查看详情</button></td>'+
								   ' </tr>';
							
							var aa=data[k].create.substr(0,10).replace("-",",");
							aa =aa.replace("-",",");
							_time.push(aa);
							var date = new Date(_time);
							_time.push(date.getTime());
							// alert(date.getTime());
							
						}
						

					}
					
				} 

			html +=	 ' </tbody>'+
					'</table>';
					
				$("#quesList").html(html);
				$(".dl-bg").click(function(){
					var to = $(this).data("id");
					var knowledge = $(this).data("knowledge");
					var cid = $(this).data("cid");
					// var clname = CurrentUser.Class;
					var clname = "";
					var chid = $(this).data("chid");
					window.location.href = "a_message.html?to=" + to + "&knowledge=" + knowledge + "&cid=" + cid + "&clname=" + clname + "&chid=" + chid;
				});
			}
		});
	},
	examErrorInit: function(){
		var pag = Course.myPage;
		var kk = 0;
		var countPage = 20;//每页显示个数
		if(pag == undefined || pag<0){
			Course.myPage=1;
		}
		else{
			kk = pag*countPage-countPage;
			Course.myPage=pag;
		}
		$ajax({
			url: "/errorset/listErrSet",
			data:{
				start: kk,
				count: countPage,
				cid: $.query.get("id")
			},
			success: function(res){
				var fmres = res;
				var res = res.result.results;
				var id = $.query.get("id");
				var pro = $.query.get('pro');
				var html = "<ul style='font-size:14px'>";
				if(pag > 1)
    				var NUM = parseInt((pag-1)*20+1);
    			else 
    				var NUM = 1;
    			if(res != '' && res != undefined){
    				for (var i = 0; i < res.length; i ++){
						var content = "";
						if(res[i].Content.length >= 40) {
							content = res[i].Content.substr(0, 40) + "......";
						}else {
							content = res[i].Content;
						}
						// 添加if修改
						//html += '<li data-id="' + res[i]._id + '" class="aabbcc">' + (i + 1) + '.' + content + '<span><a href="#">查看详细</a></span></li>';
						html += '<li>' + (NUM++) + '.' + content + '<span data-id="' + res[i].Id + '" class="aabbcc" style= "cursor:pointer">查看详细</span></li>';
						
					}
					html += '</ul>';
    			}

	            //分页
	            var sumPage = Math.ceil(fmres.result.count/countPage);
	            var pagehtml = '';
	            var numPage = Course.myPage;
            	if(Course.myPage == 1)//查看当前页码
            		pagehtml += '<span class="courBgc">上一页</span>';
            	else
            		pagehtml += '<span class="prev">上一页</span>';

            	for(var p1=0;p1<3;p1++){
            		var pp = numPage;
            		if(numPage<sumPage)
            			pagehtml += '<span class="clinum" data-pnum="'+(pp++)+'">'+ (numPage++) +'</span>';
            		else if(numPage==sumPage)
            			pagehtml += '<span class="clinum" data-pnum="'+ (sumPage) +'">'+ (numPage++) +'</span>';
            	}
            	if(sumPage>3)
            		pagehtml += '...';
            	if(Course.myPage == sumPage)	
            		pagehtml += '<span class="courBgc">下一页</span>';
            	else		
            		pagehtml += '<span class="next">下一页</span>';
			    pagehtml += '<span>分页'+ Course.myPage +'/'+ sumPage +'页</span>';
	            //分页html
	            $("#page_n").html(pagehtml);
	            $(".clinum").click(function(){
	            	Course.myPage = $(this).data('pnum');
	            	Course.examErrorInit();
	            });
	            $(".prev").click(function(){
	            	Course.myPage = (Number(Course.myPage)-1);
	            	Course.examErrorInit();
	            });
	            $(".next").click(function(){
	            	Course.myPage = (Number(Course.myPage)+1);
	            	Course.examErrorInit();
	            }); 

	            // 主页面html
				if(html.length >= 40)
					$("#listMain").html(html);
				else{
					$(".news_right").css("height","450px");
					$("#listMain").html('<div class="infroNo"><span style="background:url(../img/wuNeirong.png)left center no-repeat;width:100px;height:100px;float:left"></span>我们还未记录到您做错过试题!</div>');
					$("#page_n").hide();
				}
				$(".aabbcc").click(function(){
					window.location.href = "x_index_erroCheck.html?id=" + $.query.get("id") + "&eid=" + $(this).data("id")+'&pro='+pro;
				});
				$ajax({
					url:"/course/detailCourse",
					data:{
						_id : id
					},
					success: function(res) {
						for(var nn=0;nn<CurrentUser.course.length;nn++){
							if(id == CurrentUser.course[nn].id && (CurrentUser.course[nn].noShowScore == true || CurrentUser.course[nn].noShowScore == 'true')){
								$(".wdcj").parent().hide();
							}
						}
						var items = res.result;
						$(".cont-title").text(items.name);
						window.document.title = items.name+"-我的错题-国开享学吧";
					}
				});
			}
		});
	},
	examErrorDetailInit: function(){
		$ajax({
			url: "/errorset/detailErrSet",
			data: {
				cid: $.query.get('id'),
				Id: $.query.get("eid")
			},
			success: function(res){
				var res = res.result[0];
				var html = "";
				//获取课程名
				var id = $.query.get("id");
				$ajax({
					url:"/course/detailCourse",
					data:{
						_id : id
					},
					success: function(res) {
						var items = res.result;
						$(".cont-title").text(items.name);
						window.document.title = items.name+"-我的错题详情-国开享学吧";
					}
				});
				if(res.hasOwnProperty('Tip') && res.Tip.length > 0)
					var Tip = res.Tip;
				else
					var Tip = "亲，等等~会有的......";
				if (res.QuestionType == EXAMTYPE.SINGLE_CHOICE){//单选
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + ' <span class="score" data-score="' + res.QScore + '"> ' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box">' + res.Content + '</div>';
                        for (var j = 0; j < res.QuestionOptionList.length; j ++){
                        	var isOrNotChecked = "";
                        	if (res.stuAnswer[0] == res.QuestionOptionList[j].Id)
                        		isOrNotChecked = "checked";
                        	html += '<span>' + 
                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res.QuestionOptionList[j].IfRightAnswer + '" name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '">' + res.QuestionOptionList[j].Content + '</label>' + 
                                    '</span>';
                        }      
                        html +=  '</div>' + '<div class="mkyl_tijiao">';
                        		 // '<h4 style="padding-left:1em;">正确答案 : </h4>';
                        		for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                        	if (res.QuestionOptionList[j].IfRightAnswer){
		                        		//html += '<div style="padding-left:1.5em;padding-top:20px;font-size:16px;"><font style="font-weight:bold">正确答案：</font>' + res.QuestionOptionList[j].Content + '</div>';
		                        		html += '<div class="daan daan-1">正确答案：<xmp>' + res.QuestionOptionList[j].Content + '</xmp></div>';
		                        	}          		
		                        }

		                html +='<div class="jiexi" style ="font-size:16px;">'+
								'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;"><xmp>'+Tip +'</xmp></div></div>';

                        html += '</div>'+'</div>'; 

				}
				else if (res.QuestionType == EXAMTYPE.MULTIPLE_CHOICE){//多选
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + ' <span class="score" data-score="' + res.QScore + '"> ' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box">' + res.Content + '</div>';
                        for (var j = 0; j < res.QuestionOptionList.length; j ++){
                        	var isOrNotChecked = "";
                        	for (var k = 0; k < res.stuAnswer.length; k ++){     
	                        	if (res.stuAnswer[k] == res.QuestionOptionList[j].Id)
	                        		isOrNotChecked = "checked";
                        	}
                        	html += '<span>' + 
                        	'<label><input type="checkbox" ' + isOrNotChecked + ' data-ifrightanswer="' + res.QuestionOptionList[j].IfRightAnswer + '" name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '"><xmp>' + res.QuestionOptionList[j].Content + '</xmp></label>' + 
                                    '</span>';
                        }      
                        html +=  '</div>' + '<div class="mkyl_tijiao">'+
                        		'<div class="daan daan-1" style="font-size:16px;">正确答案：<xmp>';
                        		//'<div style="padding-left:1.5em;padding-top:20px;font-size:16px;"><font style="font-weight:bold">正确答案：</font>';
                        		 // '<h4 style="padding-left:1em;">正确答案 : </h4>';
                        		for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                        	if (res.QuestionOptionList[j].IfRightAnswer){
		                        		html += res.QuestionOptionList[j].Content +"  ";
		                        	}          		
		                        }
		                        html += '</xmp></div>';
		                html += 
		                		'<div class="jiexi" style ="font-size:16px;">'+
								'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;"><xmp>'+Tip +'</xmp></div></div>';

                        html += '</div>' + '</div>';   
				}
				else if (res.QuestionType == EXAMTYPE.JUDGE){//判断
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + ' <span class="score" data-score="' + res.QScore + '"> ' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box">' + res.Content + '</div>';
                        for (var j = 0; j < res.QuestionOptionList.length; j ++){
                        	var isOrNotChecked = "";
                        	if (res.stuAnswer[0] == res.QuestionOptionList[j].Id)
                        		isOrNotChecked = "checked";
                        	html += '<span>' + 
                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res.QuestionOptionList[j].IfRightAnswer + '" name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '">' + res.QuestionOptionList[j].Content + '</label>' + 
                                    '</span>';
                        }      
                        html +=  '</div>' + '<div class="mkyl_tijiao">';
                        		 // '<h4 style="padding-left:1em;">正确答案 : </h4>';
                        		for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                        	if (res.QuestionOptionList[j].IfRightAnswer){
		                        		//html +='<div style="padding-left:1.5em;padding-top:20px;font-size:16px;"><font style="font-weight:bold">正确答案：</font>' + res.QuestionOptionList[j].Content + '</div>';
		                        		html +='<div class="daan daan-1" style ="font-size:16px;">正确答案：' + res.QuestionOptionList[j].Content + '</div>';
		                        	}          		
		                        }
		                 html += 
		                		'<div class="jiexi" style ="font-size:16px;">'+
								'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;">'+Tip +'</div></div>';

                        html += '</div>' + '</div>';        
				}
				else if (res.QuestionType == EXAMTYPE.FILL){//填空
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + '<span class="score" data-score="' + res.QScore + '"> ' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box">' + res.Content + '</div>' + 
                        			'<label><input type="text" id="' + res.Id + '"></label>';
                        			for ( var j = 0; j < res.QuestionOptionList.length; j ++){
                        				html += '<input type="hidden" id="' + res.QuestionOptionList[j].Id + '" value="' + res.QuestionOptionList[j].Content + '">';
                        			}
                       	html += '</div>' + 
                            '</div>';  
                    html += 
		                		'<div class="jiexi" style ="font-size:16px;">'+
								'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;">'+Tip +'</div></div>';

				}
				else if (res.QuestionType == EXAMTYPE.SUBJECTIVE){//问答
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + '<span class="score" data-score="' + res.QScore + '"> ' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box">' + res.Content + '</div>' + 
                        			'<label><textarea type="text" id="' + res.Id + '"></textarea></label>';
                        			for ( var j = 0; j < res.QuestionOptionList.length; j ++){
                        				html += '<input type="hidden" id="' + res.QuestionOptionList[j].Id + '" value="' + res.QuestionOptionList[j].Content + '">';
                        			}
                       	html += '</div>' + 
                            '</div>';  
                    html += 
		                		'<div class="jiexi" style ="font-size:16px;">'+
								'<div class="left jiexi-left" style ="font-weight: bold;font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;">'+Tip +'</div></div>';

				}
				else if (res.QuestionType == EXAMTYPE.LIGATURE){//连线
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title" style="margin-top:0">' + res.QtypeString + '<span class="score" data-score="' + res.QScore + '"> ' +
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-zw">' + 
                                    '<div class="mkyl-box" style="border-bottom:none;margin-left:1.5em">' + res.Content + '</div>' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:67%;margin-left:2.2em;height: 14em;">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                            	if (res.QuestionOptionList[j].OrderNum%2 == 1){
		                            		left += '<div class="matchOne lianxian" style="font-size:16px" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res.QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" style="font-size:16px" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right +
                       			'</div>'; + 
                            '</div>'; 
                        		html += '<div style="padding-left:3em;">点击下面内容查看正确答案 : </div>' + 
                        		'<ul style="font-size:16px">' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:70%;border-bottom:none;height: 12em;">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                            	if (res.QuestionOptionList[j].OrderNum%2 == 1){
		                            		for (var l = 0; l < res.QuestionOptionList.length; l ++){
		                            			if (res.QuestionOptionList[l].OrderNum == res.QuestionOptionList[j].OrderNum+1)
		                            				var ans = res.QuestionOptionList[l].Id;
		                            		}
		                            		left += '<div class="matchOne lianxian" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res.QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '0">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>'; 
                        html += 
		                		'<div class="jiexi" style="border:none">' +
								'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析 : </div>'+
								'<div class="right jiexi-right" style="line-height:200%;">'+Tip +'</div></div>';

				}
				else if (res.QuestionType == EXAMTYPE.SORT){//排序
					//冒泡排序,用于正解
					var temp = 0;
					var targetArr = res.QuestionOptionList;
		            for(var i = 0;i<targetArr.length;i++){
		                for(var j = i;j<targetArr.length;j++){
		                    if(targetArr[i].OrderNum>targetArr[j].OrderNum){
		                        temp = targetArr[i];
		                        targetArr[i] = targetArr[j];
		                        targetArr[j] = temp;
		                     }
		                 }
		            }
					html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res.QuestionType + '" data-id="' + res.Id + '">' + 
                                '<div class="mkyl-title">' + res.QtypeString + '<span class="score" style="font-size:16px" data-score="' + res.QScore + '">' + 
                                //res.QScore + 注释掉分数
                                '</span></div>' + 
                                '<div class="mkyl-box" style="border-bottom:none">' + res.Content + '</div>' + 
                                '<div class="custom_order" style="font-size:16px" id="custom_order">' + 
			                    '    <div class="custom_sort_form">' + 
			                    '        <ul class="sort_div" id="sort_div">';
			                  //alert('res.QuestionOptionList.length=' + res.QuestionOptionList.length + "  res.stuAnswer.length=" + res.stuAnswer.length);
                        for (var j = 0; j < res.stuAnswer.length; j ++){
                        	for (var l = 0; l < res.QuestionOptionList.length; l ++){
                        		if (res.stuAnswer[j] == res.QuestionOptionList[l].Id){
                        			html += '<li id="' + res.QuestionOptionList[l].Id + '" data-ordernum="' + res.QuestionOptionList[l].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
			                                '    <div class="v_middle" id="' + res.QuestionOptionList[l].Id + '_h" style="cursor: move;">' + res.QuestionOptionList[l].Content + '</div>' + 
			                                '</li>';
                        		}
                        	}
                        }      
	                    html +=  '</ul>' + '<div class="mkyl_tijiao">'+
	                    		 '<div class="daan daan-1" style="font-size:16px">正确答案：</div>';
                        		 //'<div style="padding-left:1.5em;padding-top:20px;font-size:16px">正确答案：</div>';
	                		// '<h4 style="padding-left:1em;">正确答案 : </h4>';
	                		for (var j = 0; j < targetArr.length; j ++){
                        	html += '<li style="font-size:16px" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;">' + 
	                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
	                                '</li>';
                        }
                        html += '</div>' + 
			                    '</div>' + '</div>'
			                '</div>';  
			            html += 
		                		'<div class="jiexi" style="border:none">' +
		                		'<div class="left jiexi-left" style ="font-size:16px;font-weight: bold;">解析 : </div>'+
		                		'<div class="right jiexi-right" style="line-height:200%;">'+Tip +'</div></div>';

				}
				$("#errorDetail").html(html);
				// 初始化连线canvas
				var mblBoxs=$(".matchByLineBox");
				mblArr=[];//全局 存储所有mbl实例
				mblBoxs.each(function(x){
					var mbl=new MatchByLine(mblBoxs.eq(x));
					mbl.init();
					mblArr.push(mbl);
				});
				if (res.QuestionType == EXAMTYPE.LIGATURE){
					for (var k = 0; k < res.stuAnswer.length/2; k ++){     
                    	addOneMatchLineAns({"id": res.stuAnswer[2*k],"answer" : res.stuAnswer[2*k+1]});
                	}
				}
				// 初始化拖动排序
				initDrag();
			}
		});
	},
	examListInit: function(){
		var data = {};
		if (CurrentUser.utype == UTYPE.STUDENT ||CurrentUser.utype == UTYPE.STUDENT_ENTER ||CurrentUser.utype == UTYPE.STUDENT_TRY)
			data.courseId = $.query.get("id");
		var url = "/examine/listPage";
		if(CurrentUser.utype==UTYPE.TUTOR)
			url = "/examine/stuExamStatusList";
		$ajax({
			url : url,
			data: {
			        id: CurrentUser._id,
				    utype: CurrentUser.utype,
				    courseId: data.courseId,
				    etype: 2
				   },
			success: function(res){
				var data = res.result;
				var pro = $.query.get('pro');
				if(CurrentUser.utype == UTYPE.STUDENT)
					data = res.result.result;
				var html = '';
				var tutor = '';
				if(CurrentUser.utype == 40) {
					html += '<table cellpadding="0" cellspacing="0" width="100%" style="border-top:1px solid #cccccc;border-left:1px solid #cccccc">'+
	                        	'<tr style="background:#F5F5F5">'+
						   			'<td>考试类型</td>'+
						   			'<td>考试成绩</td>'+
						   			'<td>时间</td>'+
						   			'<td>操作</td>'+
						   		'</tr>';
					for (var i=0; i<data.length; ++i) {
		            	html += '<tr data-num="'+ i +'">'+
		            				'<td>'+ (data[i].etype == 1?"阶段测试":"结业考试") +'</td>'+
		            				'<td>'+ (data[i].isLabour == true?"未阅卷":data[i].score+"分") +'</td>'+ 
		            				'<td>'+ (new Date(data[i].create)).pattern("yyyy-MM-dd") +'</td>'+ 
		            				'<td>'+
			            			'	<a data-labour="' + data[i].isLabour + '" data-id="' + data[i]._id + '" data-homeworkid="' + data[i].homeworkId + '" class="viBtn">'+
	                                		'<span class="span-btn">查看详细</span>'+
	                                '	</a>'+
	                            	'</td>'+
		            			'</tr>';
		            }
		            html += '</table>';

				}else {
					if (CurrentUser.utype == UTYPE.TUTOR)
						tutor = '<th style="text-align:center;">学生姓名</th>';
					html += '<table class="table table-bordered" style="vertical-align:none"><thead><tr>'+tutor +
	                        '	<th style="text-align:center;">班级（订单）名称</th>'+
	                        '	<th style="text-align:center;">考试时间</th>'+ 
	                        '	<th style="text-align:center;">考试成绩</th>'+ 
	                        '	<th style="text-align:center;">操作</th>'+
		                    '</tr></thead><tbody>';
		            for (var i=0; i<data.length; ++i) {
		            	var stuName = '';
						if (CurrentUser.utype == UTYPE.TUTOR)
							stuName = '<td>'+ data[i].name +'</td>';
		            	html += '<tr data-num="'+ i +'">'+stuName + 
		            				'<td>'+ data[i].orderName+'</td>'+
		            				'<td>'+ data[i].create.substr(0,10) +'</td>'+ 
		            				'<td>'+ (data[i].isLabour == true?'暂未评分':data[i].score) +'</td>'+ 
		            				// '<td>'+ Course.etype[data[i].etype] +'</td>'+ 
		            				'<td>'+
			            			'	<a data-id="' + data[i]._id + '" data-homeworkid="' + data[i].homeworkId + '" class="btn btn-success btn-sm viewBtn" href="#">'+
	                                '    		查看考试内容'+
	                                '	</a>'+
	                            	'</td>'+
		            			'</tr>';
		            }
		            html += '</tbody></table>';
				}
	            $("#listCtn").html(html);
	            if(html.length>220)
	            	$(".news-bhe-tab").html(html);
	        	else{
	        		$(".news_right_dy").css("height","450px");
	        		$(".news_right_dy").css("border","1px solid #cccccc");
	        		$(".news_right_dy").html('<div class="infroNo"><span style="background:url(../img/wuNeirong.png)-180px center no-repeat;width:100px;height:100px;float:left"></span>您还没有参加过结业考试!</div>');
	        	}
	            var id = $.query.get("id");
	            if(CurrentUser.utype == 40) {
					$ajax({
						url:"/course/detailCourse",
						data:{
							_id : id
						},
						success: function(res) {
							for(var nn=0;nn<CurrentUser.course.length;nn++){
								if(id == CurrentUser.course[nn].id && (CurrentUser.course[nn].noShowScore == true || CurrentUser.course[nn].noShowScore == 'true')){
									$(".wdcj").parent().hide();
								}
							}
							var items = res.result;
							$(".cont-title").text(items.name);
							window.document.title = items.name+"-考试记录-国开享学吧";
						}
					});
				}
	            $(".viewBtn").click(function(){//辅导老师 查看跳转
	            	window.location.href = "a_examDetail.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id");
	            });
	            $(".viBtn").click(function(){//学员 查看跳转
	            	if($(this).data("labour")) {
	            		window.location.href = "x_index_notFraction.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id")+"&pro="+pro;
	            	}else {
	            		window.location.href = "x_index_fraction.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id")+"&pro="+pro;
	            	}
	            });
			}
		});
	},
	proExamList: function(){
		var data = {};
		if (CurrentUser.utype == UTYPE.STUDENT ||CurrentUser.utype == UTYPE.STUDENT_ENTER ||CurrentUser.utype == UTYPE.STUDENT_TRY)
			data.courseId = $.query.get("id");
		var url = "/examine/listPage";
		if(CurrentUser.utype==UTYPE.TUTOR)
			url = "/examine/stuExamStatusList";
		$ajax({
			url : url,
			data: {
			        id: CurrentUser._id,
				    utype: CurrentUser.utype,
				    courseId: data.courseId
				   },
			success: function(res){
				var items = res.result.result;
				var pro = $.query.get('pro');
				function showList(items){
					var ehtml = '';
					if(CurrentUser.utype == UTYPE.STUDENT){
						ehtml +='<table width="100%">'+
						            '<thead>'+
						                '<tr bgcolor="#F5F5F5" class="c9" style="height: 40px;">'+
						                    '<th width="20%">作业/考试</th>'+
						                    '<th width="18%">成绩</th>'+
						                    '<th width="18%">提交时间</th>'+
						                    '<th width="18%">我的评价</th>'+
						                    '<th width="">操作</th>'+
						                '</tr>'+
						            '</thead>'+
						            '<tbody>';
						for(var i=0; i<items.length; i++){
							if(items[i].etype == 0)
								continue;
							var stacss = '';
							if(items[i].hasOwnProperty('star') && items[i].star != 0){
								for(var s=0; s<items[i].star;s++){
									stacss += '<li class="cur"></li>';
								}
								for(var f=0; f<(5-items[i].star); f++){
									stacss += '<li></li>';
								}
							}else{
								for(var f=0; f<5; f++){
									stacss += '<li></li>';
								}
							}
							ehtml +='<tr>'+
					                    '<td>'+ (items[i].etype == 1?'阶段作业':'结业考试') +'</td>'+
					                    '<td>'+ (items[i].isLabour == true?"未阅卷":items[i].score+"分") +'</td>'+
					                    '<td>'+ (new Date(items[i].create)).pattern('yyyy-MM-dd') +'</td>'+
					                    '<td>'+
					                    	'<div style="padding-top:5px;">'+
					                    		'<ul class="heart-grade js_herat_add_end">'+
					                    		stacss+
					                        	'</ul>'+
					                    	'</div>'+
					                   	'</td>'+
					                    '<td>'+
				            			'	<a data-labour="' + items[i].isLabour + '" data-id="' + items[i]._id + '" data-homeworkid="' + items[i].homeworkId + '" class="viBtn">'+
		                                		'<span class="span-btn">查看详细</span>'+
		                                '	</a>'+
		                            	'</td>'+
					                '</tr>';
						}
					    ehtml +='</tbody></table>';
					}else{
						if (CurrentUser.utype == UTYPE.TUTOR)
							tutor = '<th style="text-align:center;">学生姓名</th>';
						html += '<table class="table table-bordered" style="vertical-align:none"><thead><tr>'+tutor +
		                        '	<th style="text-align:center;">班级（订单）名称</th>'+
		                        '	<th style="text-align:center;">考试时间</th>'+ 
		                        '	<th style="text-align:center;">考试成绩</th>'+ 
		                        '	<th style="text-align:center;">操作</th>'+
			                    '</tr></thead><tbody>';
			            for (var i=0; i<items.length; ++i) {
			            	var stuName = '';
							if (CurrentUser.utype == UTYPE.TUTOR)
								stuName = '<td>'+ items[i].name +'</td>';
			            	html += '<tr data-num="'+ i +'">'+stuName + 
			            				'<td>'+ items[i].orderName+'</td>'+
			            				'<td>'+ items[i].create.substr(0,10) +'</td>'+ 
			            				'<td>'+ (items[i].isLabour == true?'暂未评分':items[i].score) +'</td>'+ 
			            				// '<td>'+ Course.etype[data[i].etype] +'</td>'+ 
			            				'<td>'+
				            			'	<a data-id="' + items[i]._id + '" data-homeworkid="' + items[i].homeworkId + '" class="btn btn-success btn-sm viewBtn" href="#">'+
		                                '    		查看考试内容'+
		                                '	</a>'+
		                            	'</td>'+
			            			'</tr>';
			            }
			            html += '</tbody></table>';
					}
					
					$('.profe').html(ehtml);

					//查看详情 点击事件
		            $(".viewBtn").click(function(){//辅导老师 查看跳转
		            	window.location.href = "a_examDetail.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id");
		            });
		            $(".viBtn").click(function(){//学员 查看跳转
		            	if($(this).data("labour")) {
		            		window.location.href = "x_index_notFraction.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id")+"&pro="+pro;
		            	}else {
		            		window.location.href = "x_index_fraction.html?id=" + $.query.get("id") + "&examId=" + $(this).data("id")+"&pro="+pro;
		            	}
		            });
				}
				showList(items);

				//集合分解以及点击事件
				var homeArray = [];
				var examArray = [];
				for(var l=0;l<res.result.count;l++){
					if(items[l].etype == 1)
						homeArray.push(items[l]);
					else if(items[l].etype == 2)
						examArray.push(items[l])
				}

				$('.eq').change(function(){
					console.log($(this).val())
					if($(this).val() == 'option1')
						showList(items);
					else if($(this).val() == 'option2')
						showList(homeArray);
					else if($(this).val() == 'option3')
						showList(examArray);
				});

				//课程名的获取
	            if(CurrentUser.utype == 40) {
					var id = $.query.get("id");
					for(var nn=0;nn<CurrentUser.course.length;nn++){
						if(id == CurrentUser.course[nn].id && (CurrentUser.course[nn].noShowScore == true || CurrentUser.course[nn].noShowScore == 'true')){
							$(".wdcj").parent().hide();
						}
					}
					$(".cont-title").text(items[0].course.name);
					window.document.title = items[0].course.name+"-考试记录-国开享学吧";
				}
			}
		})
		
		
	},
	studyExamDetailInit: function(){//因考题分类学员考试顺序显示
		$ajax({
			url : "/examine/getById",
			data: {
				_id: $.query.get("examId")
			},
			success: function(res){
				Course.items = res.result;
				var html = "";
				var readonly = "readonly";
				var type = "text";
				var border = "border:none;";
				var isStar = false;
				if(res.result.etype == '1')
					$('.cont-zj').html('阶段作业<span>评分</span>')
				if(CurrentUser.utype != 40){
					readonly = "";
					type = "number";
					border = "";
				}
				var readOnly = 'readonly="readonly"';
				if(CurrentUser.utype == UTYPE.TUTOR) {
					readOnly = '';
					if (res.result.isLabour)
						subTitle += "<h4 class='yue_juan'>未阅卷</h4>";
					else
						subTitle += '<h4 class="yue_end">'+
									'<div class="yue_juan yue_juan_bg">阅卷完毕</div>'+
									'<div>得分：'+ res.result.score +'</div>'+
									'</h4>';
				}
				$("#zzdf").html(res.result.score);
				var res = res.result.questions;
				for (var i = 0; i < res.length; i ++){
					//题干：代码图片分别显示~
					if(res[i].Content.indexOf("img") > 0)
						var resconent = '<br/>'+res[i].Content+'<br/>';
					else 
						var resconent = '<xmp>'+res[i].Content.replace(/\n/g,'</xmp><br/><xmp>').replace(/&gt;/g,'>').replace(/&lt;/g,'<').replace(/<br \/>/g,'')+'</xmp>';
					if(res[i].hasOwnProperty('Tip')){
						if(res[i].Tip.indexOf("img") > 0)
							var restip = '<br/>'+res[i].Tip+'<br/>';
						else 
							var restip = '<xmp>'+res[i].Tip.replace(/\n/g,'</xmp><br/><xmp>').replace(/&gt;/g,'>').replace(/&lt;/g,'<').replace(/<br \/>/g,'')+'</xmp>';	
				
					}else
						var restip = '';
					if(res[i].QuestionType >=4)
						isStar = true;
					if (res[i].QuestionType == EXAMTYPE.SINGLE_CHOICE){//单选
						html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + resconent + '</div>';
	                        var rightA = "";
	                        var ans = "";
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        		isOrNotChecked = "checked";
	                        		ans = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	html += '<span>' + 
	                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '"><xmp>' + res[i].QuestionOptionList[j].Content + '</xmp></label>' + 
	                                    '</span>';
	                        }   
	                        html +=     '<div class="mkyl_tijiao">';
	                        if(ans.match(rightA)) {
	                        	html += 	'<div class="daan daan-2" >正确答案：<xmp>'+rightA+'</xmp></div>';
	                        }else {
	                        	html += 	'<div class="daan daan-1" >正确答案：<xmp>'+rightA+'</xmp></div>';
	                        }
	                        html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right">'+(restip==undefined?"亲，等等~会有的......":restip)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        html +=  '</div>' + 
	                            '</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.MULTIPLE_CHOICE){//多选
						html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + resconent + '</div>';
	                        var rightA = [];
	                        var ans = [];
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	for (var k = 0; k < res[i].stuAnswer.length; k ++){     
		                        	if (res[i].stuAnswer[k] == res[i].QuestionOptionList[j].Id) {
		                        		ans.push(res[i].QuestionOptionList[j].Content);
		                        		isOrNotChecked = "checked";
		                        	}
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA.push(res[i].QuestionOptionList[j].Content);
	                        	}
	                        	html += '<span>' + 
	                                        '<label><input type="checkbox" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '"><xmp>' + res[i].QuestionOptionList[j].Content + '</xmp></label>' + 
	                                    '</span>';
	                        }      
	                        html +=     '<div class="mkyl_tijiao">';
	                        if(ans.sort().toString().match(rightA.sort().toString()) && ans.sort().length == rightA.sort().length) {
	                        	html += 	'<div class="daan daan-2">正确答案：<xmp>'+rightA+'</xmp></div>';
	                        }else {
	                        	html += 	'<div class="daan daan-1">正确答案：<xmp>'+rightA+'</xmp></div>';
	                        }
							html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right">'+(restip==undefined?"亲，等等~会有的......":restip)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        html +=  '</<div>' + 
	                            '</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.JUDGE){//判断
						html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + resconent + '</div>';
	                        var rightA = "";
	                        var ans = "";
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        		isOrNotChecked = "checked";
	                        		ans = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	html += '<span>' + 
	                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
	                                    '</span>';
	                        }   
	                        html +=     '<div class="mkyl_tijiao">'
	                        if(ans.match(rightA)) {
	                        	html += 	'<div class="daan daan-2">正确答案：'+rightA+'</div>';
	                        }else {
	                        	html += 	'<div class="daan daan-1">正确答案：'+rightA+'</div>';
	                        }
							html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="width:88%">'+(restip==undefined?"亲，等等~会有的......":restip)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        html +=  '</div>' + 
	                            '</div>';   
					}
					else if (res[i].QuestionType == EXAMTYPE.FILL){//填空
						var labour = '(需要人工阅卷)';
						var tscore = '';
						var tcomment = '';
						if (res[i].trueOrFalse != "false"){
							labour = '已阅卷';
							tscore = res[i].trueOrFalse;
							if (res[i].comment)
								tcomment = res[i].comment;
						}
						html += '<div id="' + res[i].Id + '" class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分 </span><span style="color:red;"> ' + labour + '</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + resconent +  
	                        			'<p><textarea readonly id="' + res[i].Id + '" rows="3" cols="80" class="wendati">' + (res[i].stuAnswer[0]==undefined?'':res[i].stuAnswer[0]) + '</textarea></p>';
	                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
	                        			}
	                        html += '</div>';
	                        html +=				'<div class="jiexi" style="padding-left:0;">'+
													'<div class="left jiexi-left" style="padding-left:20px;">正确答案：</div>'+
													'<div class="right jiexi-right" style="width:83%">'+(res[i].QuestionOptionList[0].Content.length<=1?"亲，等等~会有的......":res[i].QuestionOptionList[0].Content)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                       	  
	                       	html +=	 '<div class="mkyl-box">'+
			                            '<span>人工阅卷结果</span>'+
			                            '<p style="padding:10px 0 0 10px"><b >分数：</b>'+ 

			                            '<input id="fillid" max="'+ res[i].QScore +'" min="0" data-fenshu="'+ res[i].QScore +'" '+readonly+' type="'+type+'" name="score" value="' + tscore + '" style="'+border+'width:6em;outline:none"></p>'+

			                           
			                           	'<p style="padding:10px 0 0 10px"><b >点评：</b><textarea '+readonly+' rows="3" cols="75" name="comment" style="'+border+'vertical-align:top; resize:none;outline:none">'+tcomment+'</textarea></p>'+
									'</div>'+
	                       			'</div>' +
	                            '</div>'; 
					}
					else if (res[i].QuestionType == EXAMTYPE.SUBJECTIVE){//问答
						var labour = '(需要人工阅卷)';
						var tscore = '';
						var tcomment = '';
						if (res[i].trueOrFalse != "false"){
							labour = '已阅卷';
							tscore = res[i].trueOrFalse;
							if (res[i].comment)
								tcomment = res[i].comment;
						}
						html += '<div id="' + res[i].Id + '" class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分 </span><span style="color:red;"> ' + labour + '</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + resconent + 
	                                    '<p><textarea readonly id="' + res[i].Id + '" rows="3" cols="80" class="wendati">' + (res[i].stuAnswer[0]==undefined?'':res[i].stuAnswer[0]) + '</textarea></p>' +
	                        			(res[i].photo?('<p class="form-control-static"><img src="upload/' + res[i].photo + '" width="100%"></p>'):(""));
	                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
	                        			}
	                        html += '</div>';
	                        html +=				'<div class="jiexi" style="padding-left:0;">'+
													'<div class="left jiexi-left" style="padding-left:20px;">正确答案：</div>'+
													'<div class="right jiexi-right" style="width:83%;">'+(res[i].QuestionOptionList[0].Content.length<=1?"亲，等等~会有的......":res[i].QuestionOptionList[0].Content)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                       	html +=	 '<div class="mkyl-box">'+
			                            '<span>人工阅卷结果</span>'+
			                            '<p style="padding:10px 0 0 10px"><b >分数：</b>'+

			                            '<input id="subjectiveid" max="'+ res[i].QScore +'" min="0"  data-subfenshu="'+ res[i].QScore +'" '+readonly+' type="'+type+'" name="score" value="' + tscore + '" style="'+border+'width:6em;outline:none"></p>'+

			                           
			                           	'<p style="padding:10px 0 0 10px;"><b >点评：</b><textarea '+readonly+' rows="3" cols="75" name="comment" style="'+border+'vertical-align:top; resize:none;outline:none">'+tcomment+'</textarea></p>'+
									'</div>'+
	                       			'</div>' +
	                            '</div>';
					}
					else if (res[i].QuestionType == EXAMTYPE.LIGATURE){//匹配
						html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<ul>' + 
	                                    '<div class="mkyl-box" style="border-bottom:none;font-size:16px;line-height: 30px;">' + res[i].Content + '</div>' + 
	                                	'<h4 style="padding-left:1em;font-size:16px">点击下面内容查看我的答案 : </h4>' + 	                                    
	                        			'<div class="matchByLineBox mlBoxCol" style="width:70%;height:200px">';
	                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
	                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
	                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
			                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
			                            		var ans = '';
		                        				for (var k = 0; k < res[i].stuAnswer.length; k ++){
		                        					if (res[i].QuestionOptionList[j].Id == res[i].stuAnswer[k]){
		                        						ans = res[i].stuAnswer[k+1];
		                        					}
		                        				}
			                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '" ans="' + ans + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
			                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            }
			                            left += '</div>';
			                            right += '</div>';
	                       			html += left + right + 
	                       			'</ul>';
	                       			html +=  '</ul>' + 
                        		'<h4 style="padding-left:3em;font-size:16px">点击下面内容查看正确答案 : </h4>' + 
                        		'<ul style="font-size:14px">' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:70%;height:12em">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
		                            		for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
		                            			if (res[i].QuestionOptionList[l].OrderNum == res[i].QuestionOptionList[j].OrderNum+1)
		                            				var ans = res[i].QuestionOptionList[l].Id;
		                            		}
		                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>';
	                            html += '</div>';  
	                            html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="font-size:16px;">'+(res[i].Tip.length<=1?"亲，等等~会有的......":res[i].Tip)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';        
					}
					else if (res[i].QuestionType == EXAMTYPE.SORT){//排序
						var rightOrErr = 'daan-1';
						var rightAns = [];
						//判断有无解析
						if (res[i].Tip.length == 0) 
							{
								res[i].Tip = "亲，等等~会有的......";
							};
						//冒泡排序,用于正解
						var temp = 0;
						var targetArr = res[i].QuestionOptionList;
			            for(var ii = 0;ii<targetArr.length;ii++){
			                for(var j = ii;j<targetArr.length;j++){
			                    if(targetArr[ii].OrderNum>targetArr[j].OrderNum){
			                        temp = targetArr[ii];
			                        targetArr[ii] = targetArr[j];
			                        targetArr[j] = temp;
			                     }
			                 }
			            }
						html += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + res[i].QtypeString + '<span class="score" style="font-size:16px" data-score="' + res[i].QScore + '">' + 
	                                res[i].QScore + 
	                                '</span></div>' + 
	                                '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>' + 
	                                '<div class="custom_order" style="font-size:16px" id="custom_order">' + 
				                    '    <div class="custom_sort_form">' + 
				                    '        <ul class="sort_div" id="sort_div">';
	                        for (var j = 0; j < res[i].stuAnswer.length; j ++){
	                        	for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
	                        		if (res[i].stuAnswer[j] == res[i].QuestionOptionList[l].Id){
	                        			html += '<li id="' + res[i].QuestionOptionList[l].Id + '" data-ordernum="' + res[i].QuestionOptionList[l].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
				                                '    <div class="v_middle" id="' + res[i].QuestionOptionList[l].Id + '_h" style="cursor: move;">' + res[i].QuestionOptionList[l].Content + '</div>' + 
				                                '</li>';
	                        		}
	                        	}
	                        }     

	                        for (var j = 0; j < targetArr.length; j ++){
	                        	rightAns.push(targetArr[j].Id);
	                        }
	                        if(rightAns.toString() == res[i].stuAnswer.toString()){
	                        	rightOrErr = 'daan-2';
	                        }
		                    html +=  '</ul>' + '<div class="mkyl_tijiao">'+
		                    		 '<div class="daan '+rightOrErr+'" style="font-size:16px">正确答案：</div>';
	                        		 //'<div style="padding-left:1.5em;padding-top:20px;font-size:16px">正确答案：</div>';
		                		// '<h4 style="padding-left:1em;">正确答案 : </h4>';
		                		for (var j = 0; j < targetArr.length; j ++){
	                        	html += '<li style="font-size:16px" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;">' + 
		                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
		                                '</li>';
	                        }
	                        html += '</div>' + 
				                    '</div>' + '</div>'
				                '</div>';  
				           html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="font-size:16px;">'+(res[i].Tip.length<=1?"亲，等等~会有的......":res[i].Tip)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';  
					}
				}
				if (CurrentUser.utype == UTYPE.TUTOR && Course.examItems.isLabour){
					html += '<div style="text-align: right;padding: 1em 2em 1em 0;border-top:1px solid #8aadfd;"><input id="labourSubmit" type="button" class="btn btn-effect-ripple btn-primary" value="人工阅卷完毕"></div>';
				}
				$("#listCtn").html(html);
				//学员给老师评星
				var items = Course.items;
				console.log(isStar)
				if(CurrentUser.utype == UTYPE.STUDENT && items.isLabour == false && isStar){
				//if(true){
					var stacss = '';
					if(items.hasOwnProperty('star') && items.star != 0){
						for(var s=0; s<items.star;s++){
							stacss += '<li class="cur"></li>';
						}
						for(var f=0; f<(5-items.star); f++){
							stacss += '<li></li>';
						}
					}else{
						for(var f=0; f<5; f++){
							stacss += '<li></li>';
						}
					}
					var mhtml = '<div class="pal10 heartWrap">'+
		                            '<p class="float_l fs14 c9">请对本次考试主观题批改评分</p>'+
		                            '<ul class="heart-grade js_herat_add">'+
		                            	stacss+
		                            '</ul>'+
		                            '<div class="heart-submit rel">'+
		                                '<span class="fs14 c9"></span>'+
		                            '</div>'+
		                            '<p><button class="fs14 btn-danger btn_wid bg_red makSta" style="padding: 5px 0;">提交</button></p>'+
		                        '</div>';
	                $('.heartGradeWrap').html(mhtml);
	                $(".js_herat_add>li").mouseover(function(){
				        appraiseHeartAdd(this);
				    });
				    $('.makSta').click(function(){
				    	var staNum = 0;
						$(".js_herat_add>li").each(function(){
						    if($(this).attr('class') == 'cur')
						    	staNum += 1;
						});
						$ajax({
							url: '/examine/setStar',
							data: {
								id: $.query.get('examId'),
								star: staNum
							},
							success: function(res){
								$(".rateSub").addClass('hidden');
								$(".js_show").removeClass('hidden');
								setTimeout(function(){
							        $(".js_show").hide();
							    },2000);
							}
						});
				    });
				}

				$("#fillid").keyup(function(){
					var fenshu = $(this).data('fenshu');
	                var inputfenshu = parseFloat($("#fillid").val());
	                // return alert(inputfenshu);
	                if(!isNaN(inputfenshu) && inputfenshu >= 0){
	                	if(inputfenshu > fenshu){
	                		$("#fillid").val("");
	                		return alert("您输入的数值已超过本题的总分，请重新输入！！！");
	                	}
	                }else{
	                	$("#fillid").val("");
	                	return alert("请输入正确的数值！！！");
	                }
	            });
	            $("#subjectiveid").keyup(function(){
	            	var subfenshu = $(this).data('subfenshu');
	            	var inputsub = parseFloat($("#subjectiveid").val());
	            	// return alert(inputsub);
	            	if(!isNaN(inputsub) && inputsub >= 0){
	                	if(inputsub > subfenshu){
	                		$("#subjectiveid").val("");
	                		return alert("您输入的数值已超过本题的总分，请重新输入！！！");
	                	}
	                }else{
	                	$("#subjectiveid").val("");
	                	return alert("请输入正确的数值！！！");
	                }
	            })	
				if(CurrentUser.utype == 40) {
					$(".mkyl").html(html);
					// return;
				}
				// 初始化连线canvas
				var mblBoxs=$(".matchByLineBox");
				mblArr=[];//全局 存储所有mbl实例
				mblBoxs.each(function(x){
					var mbl=new MatchByLine(mblBoxs.eq(x));
					mbl.init();
					mblArr.push(mbl);
				});
				// 初始化拖动排序
				initDrag();
				$("#labourSubmit").click(Course.labourSubmit);
				var id = $.query.get("id");
				if(CurrentUser.utype == 40) {
					$ajax({
						url:"/course/detailCourse",
						data:{
							_id : id
						},
						success: function(res) {
							var items = res.result;
							$(".cont-title").text(items.name);
							window.document.title = items.name+"-考试记录详情-国开享学吧";
						}
					});
				}
				// console.log(mblArr);
				// for (var o = 0; o < res.length; o ++){
				// 	if (res[o].QuestionType == EXAMTYPE.LIGATURE){
				// 		for (var p = 0; p < res[o].stuAnswer.length/2; p ++){  
	   //                  	addOneMatchLineAns({"id": res[o].stuAnswer[2*p],"answer" : res[o].stuAnswer[2*p+1]});
	   //              	}
				// 	}
				// }
				
			}
		});	
	},
	examDetailInit: function(){
		$ajax({
			url : "/examine/getById",
			data: {
				// homeworkId: $.query.get("homeworkId"),
				// student: CurrentUser._id
				_id: $.query.get("examId")
			},
			success: function(res){
				Course.examItems = res.result;
				var html = "";//主观
				var noSubjec="";//客观
				var subTitle ="";
				var readonly = "readonly";
				var type = "text";
				var border = "border:none;";
				if(CurrentUser.utype != 40){
					readonly = "";
					type = "number";
					border = "";
				}
				var readOnly = 'readonly="readonly"';
				if(CurrentUser.utype == UTYPE.TUTOR) {
					readOnly = '';
					if (res.result.isLabour)
						subTitle += "<h4 class='yue_juan'>未阅卷</h4>";
					else
						subTitle += '<h4 class="yue_end">'+
									'<div class="yue_juan yue_juan_bg">阅卷完毕</div>'+
									'<div>得分：'+ res.result.score +'</div>'+
									'</h4>';
				}
				$("#zzdf").html(res.result.score);
				var res = res.result.questions;
				for (var i = 0; i < res.length; i ++){
					var Tip = '亲，等等~会有的......';
					if(res[i].hasOwnProperty('Tip'))
						Tip = res[i].Tip;
					if (res[i].QuestionType == EXAMTYPE.SINGLE_CHOICE){//单选
						noSubjec += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + res[i].Content + '</div>';
	                        var rightA = "";
	                        var ans = "";
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        		isOrNotChecked = "checked";
	                        		ans = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	noSubjec += '<span>' + 
	                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
	                                    '</span>';
	                        }   
	                        noSubjec +=     '<div class="mkyl_tijiao">'
	                        if(ans.match(rightA)) {
	                        	noSubjec += 	'<div class="daan daan-2" >正确答案：'+rightA+'</div>';
	                        }else {
	                        	noSubjec += 	'<div class="daan daan-1" >正确答案：'+rightA+'</div>';
	                        }
							noSubjec +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right">'+ Tip +'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        noSubjec +=  '</div>' + 
	                            '</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.MULTIPLE_CHOICE){//多选
						noSubjec += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + res[i].Content + '</div>';
	                        var rightA = [];
	                        var ans = [];
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	for (var k = 0; k < res[i].stuAnswer.length; k ++){     
		                        	if (res[i].stuAnswer[k] == res[i].QuestionOptionList[j].Id) {
		                        		ans.push(res[i].QuestionOptionList[j].Content);
		                        		isOrNotChecked = "checked";
		                        	}
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA.push(res[i].QuestionOptionList[j].Content);
	                        	}
	                        	noSubjec += '<span>' + 
	                                        '<label><input type="checkbox" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
	                                    '</span>';
	                        }      
	                        noSubjec +=     '<div class="mkyl_tijiao">'
	                        //alert('111'+ans.sort().length);
	                        //alert('222'+rightA.sort().length)
	                        if(ans.sort().toString().match(rightA.sort().toString()) && ans.sort().length == rightA.sort().length) {
	                        	noSubjec += 	'<div class="daan daan-2">正确答案：'+rightA+'</div>';
	                        }else {
	                        	noSubjec += 	'<div class="daan daan-1">正确答案：'+rightA+'</div>';
	                        }
							noSubjec +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right">'+ Tip +'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        noSubjec +=  '</<div>' + 
	                            '</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.JUDGE){//判断
						noSubjec += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + res[i].Content + '</div>';
	                        var rightA = "";
	                        var ans = "";
	                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	var isOrNotChecked = "";
	                        	if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        		isOrNotChecked = "checked";
	                        		ans = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	if(res[i].QuestionOptionList[j].IfRightAnswer) {
	                        		rightA = res[i].QuestionOptionList[j].Content;
	                        	}
	                        	noSubjec += '<span>' + 
	                                        '<label><input type="radio" ' + isOrNotChecked + ' data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
	                                    '</span>';
	                        }   
	                        noSubjec +=     '<div class="mkyl_tijiao">'
	                        if(ans.match(rightA)) {
	                        	noSubjec += 	'<div class="daan daan-2">正确答案：'+rightA+'</div>';
	                        }else {
	                        	noSubjec += 	'<div class="daan daan-1">正确答案：'+rightA+'</div>';
	                        }
							noSubjec +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="width:88%">'+ Tip +'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                        noSubjec +=  '</div>' + 
	                            '</div>';   
					}
					else if (res[i].QuestionType == EXAMTYPE.FILL){//填空
						var labour = '(需要人工阅卷)';
						var tscore = '';
						var tcomment = '';
						if (res[i].trueOrFalse != "false"){
							labour = '已阅卷';
							tscore = res[i].trueOrFalse;
							if (res[i].comment)
								tcomment = res[i].comment;
						}
						html += '<div id="' + res[i].Id + '" class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分 </span><span style="color:red;"> ' + labour + '</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + res[i].Content +  
	                        			'<p><textarea readonly id="' + res[i].Id + '" rows="3" cols="80" class="wendati">' + (res[i].stuAnswer[0]==undefined?'':res[i].stuAnswer[0]) + '</textarea></p>';
	                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
	                        			}
	                        html += '</div>';
	                        html +=				'<div class="jiexi" style="padding-left:0;">'+
													'<div class="left jiexi-left" style="padding-left:20px;">正确答案：</div>'+
													'<div class="right jiexi-right" style="width:83%">'+(res[i].QuestionOptionList[0].Content.length<=1?"亲，等等~会有的......":res[i].QuestionOptionList[0].Content)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                       	  
	                       	html +=	 '<div class="mkyl-box">'+
			                            '<span>人工阅卷结果</span>'+
			                            '<p style="padding:10px 0 0 10px"><b >分数：</b>'+ 

			                            '<input id="fillid" max="'+ res[i].QScore +'" min="0" data-fenshu="'+ res[i].QScore +'" '+readonly+' type="'+type+'" name="score" value="' + tscore + '" style="'+border+'width:6em;outline:none"></p>'+

			                           
			                           	'<p style="padding:10px 0 0 10px"><b >点评：</b><textarea '+readonly+' rows="3" cols="75" name="comment" style="'+border+'vertical-align:top; resize:none;outline:none">'+tcomment+'</textarea></p>'+
									'</div>'+
	                       			'</div>' +
	                            '</div>'; 
	                       
					}
					else if (res[i].QuestionType == EXAMTYPE.SUBJECTIVE){//问答
						var labour = '(需要人工阅卷)';
						var tscore = '';
						var tcomment = '';
						if (res[i].trueOrFalse != "false"){
							labour = '已阅卷';
							tscore = res[i].trueOrFalse;
							if (res[i].comment)
								tcomment = res[i].comment;
						}
						html += '<div id="' + res[i].Id + '" class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分 </span><span style="color:red;"> ' + labour + '</span></div>' + 
	                                '<div class="mkyl-zw">' + 
	                                    '<div class="mkyl-box" style="font-size:16px;line-height: 30px;">' + res[i].Content +  
	                        			'<p><textarea readonly id="' + res[i].Id + '" rows="3" cols="80" class="wendati">' + (res[i].stuAnswer[0]==undefined?'':res[i].stuAnswer[0]) + '</textarea></p>' +
	                        			(res[i].photo?('<p class="form-control-static"><img src="upload/' + res[i].photo + '" width="100%"></p>'):(""))+
	                        			(res[i].doc?('<p class="form-control-static">'+res[i].doc+'<button data-name="'+res[i].doc+'" class="download" style="padding:0.5em;">文档下载</button></p>'):(""));
	                        			for ( var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        				html += '<input type="hidden" id="' + res[i].QuestionOptionList[j].Id + '" value="' + res[i].QuestionOptionList[j].Content + '">';
	                        			}
	                        html += '</div>';
	                        html +=				'<div class="jiexi" style="padding-left:0;">'+
													'<div class="left jiexi-left" style="padding-left:20px;">正确答案：</div>'+
													'<div class="right jiexi-right" style="width:83%;">'+(res[i].QuestionOptionList[0].Content.length<=1?"亲，等等~会有的......":res[i].QuestionOptionList[0].Content)+'</div>'+
												'</div>'+
											'</div>'+
										'</div>';   
	                       	html +=	 '<div class="mkyl-box">'+
			                            '<span>人工阅卷结果</span>'+
			                            '<p style="padding:10px 0 0 10px"><b >分数：</b>'+

			                            '<input id="subjectiveid" max="'+ res[i].QScore +'" min="0"  data-subfenshu="'+ res[i].QScore +'" '+readonly+' type="'+type+'" name="score" value="' + tscore + '" style="'+border+'width:6em;outline:none"></p>'+

			                           
			                           	'<p style="padding:10px 0 0 10px;"><b >点评：</b><textarea '+readonly+' rows="3" cols="75" name="comment" style="'+border+'vertical-align:top; resize:none;outline:none">'+tcomment+'</textarea></p>'+
									'</div>'+
	                       			'</div>' +
	                            '</div>';
					}
					else if (res[i].QuestionType == EXAMTYPE.LIGATURE){//匹配
						html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></div>' + 
	                                '<ul>' + 
	                                    '<div class="mkyl-box" style="border-bottom:none;font-size:16px;line-height: 30px;">' + res[i].Content + '</div>' + 
	                                	'<h4 style="padding-left:1em;font-size:16px">点击下面内容查看我的答案 : </h4>' + 	                                    
	                        			'<div class="matchByLineBox mlBoxCol" style="width:70%;height:200px">';
	                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
	                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
	                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
			                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
			                            		var ans = '';
		                        				for (var k = 0; k < res[i].stuAnswer.length; k ++){
		                        					if (res[i].QuestionOptionList[j].Id == res[i].stuAnswer[k]){
		                        						ans = res[i].stuAnswer[k+1];
		                        					}
		                        				}
			                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '" ans="' + ans + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
			                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            }
			                            left += '</div>';
			                            right += '</div>';
	                       			html += left + right + 
	                       			'</ul>';
	                       			html +=  '</ul>' + 
                        		'<h4 style="padding-left:3em;font-size:16px">点击下面内容查看正确答案 : </h4>' + 
                        		'<ul style="font-size:14px">' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:70%;height:12em">';
                        			var left = '<div class="matchSide matchSideQue" style="border:none">';
                        			var right = '<div class="matchSide matchSideAns" style="border:none">';
                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
		                            		for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
		                            			if (res[i].QuestionOptionList[l].OrderNum == res[i].QuestionOptionList[j].OrderNum+1)
		                            				var ans = res[i].QuestionOptionList[l].Id;
		                            		}
		                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>';
	                            html += '</div>';  
	                            html +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="font-size:16px;">'+ Tip +'</div>'+
												'</div>'+
											'</div>'+
										'</div>';        
					}
					else if (res[i].QuestionType == EXAMTYPE.SORT){//排序
						var rightOrErr = 'daan-1';
						var rightAns = [];
						//冒泡排序,用于正解
						var temp = 0;
						var targetArr = res[i].QuestionOptionList;
			            for(var ii = 0;ii<targetArr.length;ii++){
			                for(var j = ii;j<targetArr.length;j++){
			                    if(targetArr[ii].OrderNum>targetArr[j].OrderNum){
			                        temp = targetArr[ii];
			                        targetArr[ii] = targetArr[j];
			                        targetArr[j] = temp;
			                     }
			                 }
			            }
						noSubjec += '<div class="cnt" style="line-height:200%;font-size:16px" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
	                                '<div class="mkyl-title">' + res[i].QtypeString + '<span class="score" style="font-size:16px" data-score="' + res[i].QScore + '">' + 
	                                res[i].QScore + 
	                                '</span></div>' + 
	                                '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>' + 
	                                '<div class="custom_order" style="font-size:16px" id="custom_order">' + 
				                    '    <div class="custom_sort_form">' + 
				                    '        <ul class="sort_div" id="sort_div">';
	                        for (var j = 0; j < res[i].stuAnswer.length; j ++){
	                        	for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
	                        		if (res[i].stuAnswer[j] == res[i].QuestionOptionList[l].Id){
	                        			noSubjec += '<li id="' + res[i].QuestionOptionList[l].Id + '" data-ordernum="' + res[i].QuestionOptionList[l].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
				                                '    <div class="v_middle" id="' + res[i].QuestionOptionList[l].Id + '_h" style="cursor: move;">' + res[i].QuestionOptionList[l].Content + '</div>' + 
				                                '</li>';
	                        		}
	                        	}
	                        }     

	                        for (var j = 0; j < targetArr.length; j ++){
	                        	rightAns.push(targetArr[j].Id);
	                        }
	                        if(rightAns.toString() == res[i].stuAnswer.toString()){
	                        	rightOrErr = 'daan-2';
	                        }
		                    noSubjec +=  '</ul>' + '<div class="mkyl_tijiao">'+
		                    		 '<div class="daan '+rightOrErr+'" style="font-size:16px">正确答案：</div>';
	                        		 //'<div style="padding-left:1.5em;padding-top:20px;font-size:16px">正确答案：</div>';
		                		// '<h4 style="padding-left:1em;">正确答案 : </h4>';
		                		for (var j = 0; j < targetArr.length; j ++){
	                        	noSubjec += '<li style="font-size:16px" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;">' + 
		                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
		                                '</li>';
	                        }
	                        noSubjec += '</div>' + 
				                    '</div>' + '</div>'
				                '</div>';  
				           noSubjec +=				'<div class="jiexi">'+
													'<div class="left jiexi-left" style="font-size:16px;font-weight: bold;">解析：</div>'+
													'<div class="right jiexi-right" style="font-size:16px;">'+ Tip +'</div>'+
												'</div>'+
											'</div>'+
										'</div>';  
					}
				}
				if (CurrentUser.utype == UTYPE.TUTOR && Course.examItems.isLabour){
					html += '<div style="text-align: right;padding: 1em 2em 1em 0;border-top:1px solid #8aadfd;"><input id="labourSubmit" type="button" class="btn btn-effect-ripple btn-primary" value="人工阅卷完毕"></div>';
				}
				//$("#listCtn").html(html);
				$("#subTitle").html(subTitle);
				$("#subjec").html(html);
				$("#noSubjec").html(noSubjec);
				$("#fillid").keyup(function(){
					var fenshu = $(this).data('fenshu');
	                var inputfenshu = parseFloat($("#fillid").val());
	                // return alert(inputfenshu);
	                if(!isNaN(inputfenshu) && inputfenshu >= 0){
	                	if(inputfenshu > fenshu){
	                		$("#fillid").val("");
	                		return alert("您输入的数值已超过本题的总分，请重新输入！！！");
	                	}
	                }else{
	                	$("#fillid").val("");
	                	return alert("请输入正确的数值！！！");
	                }
	            });
	            $("#subjectiveid").keyup(function(){
	            	var subfenshu = $(this).data('subfenshu');
	            	var inputsub = parseFloat($("#subjectiveid").val());
	            	// return alert(inputsub);
	            	if(!isNaN(inputsub) && inputsub >= 0){
	                	if(inputsub > subfenshu){
	                		$("#subjectiveid").val("");
	                		return alert("您输入的数值已超过本题的总分，请重新输入！！！");
	                	}
	                }else{
	                	$("#subjectiveid").val("");
	                	return alert("请输入正确的数值！！！");
	                }
	            });
	            $(".download").click(function(){
					window.open(Core.DOC_VER + $(this).data('name'));
				});
				if(CurrentUser.utype == 40) {
					$(".mkyl").html(html);
					// return;
				}
				// 初始化连线canvas
				var mblBoxs=$(".matchByLineBox");
				mblArr=[];//全局 存储所有mbl实例
				mblBoxs.each(function(x){
					var mbl=new MatchByLine(mblBoxs.eq(x));
					mbl.init();
					mblArr.push(mbl);
				});
				// 初始化拖动排序
				initDrag();
				$("#labourSubmit").click(Course.labourSubmit);
				var id = $.query.get("id");
				if(CurrentUser.utype == 40) {
					$ajax({
						url:"/course/detailCourse",
						data:{
							_id : id
						},
						success: function(res) {
							var items = res.result;
							$(".cont-title").text(items.name);
							window.document.title = items.name+"-考试记录详情-国开享学吧";
						}
					});
				}
				// console.log(mblArr);
				// for (var o = 0; o < res.length; o ++){
				// 	if (res[o].QuestionType == EXAMTYPE.LIGATURE){
				// 		for (var p = 0; p < res[o].stuAnswer.length/2; p ++){  
	   //                  	addOneMatchLineAns({"id": res[o].stuAnswer[2*p],"answer" : res[o].stuAnswer[2*p+1]});
	   //              	}
				// 	}
				// }
				
			}
		});	
	},
	editFreeInit: function() {
		var id = $.query.get("id");
		Course.freeXgCourses(id);
		$ajax({
			url:"/course/detailCourse",
			data:{
				_id : id
			},
			success: function(res) {
				var items = res.result;
			    Course.items = items;
				var html="";
				
				if(Course.items.teachers[0]!=undefined){
					html+=	'<div class="cour-art-teacher">'+
							'	<div class="daP-list-title">'+
							'		<span >主讲老师</span>'+
							'	</div>'+
							'	<div class="cour-box"> '+
							'		<div class="teacher">'+
							'			<div class="fl"><img src=/upload/'+Course.items.teachers[0].photo+'></div>'+
							'			<div class="fl">'+
							'				<p style="width:120px;">'+ Course.items.teachers[0].name+'</p>'+
							'				<p></p>'+
							'			</div>'+
							'		</div>'+
							'		<div class="clear"></div>'+
							'		<div class="teacher-intro fs14" style="height:auto">'+
							'			<p>'+ Course.items.teachers[0].des+'</p>'+
							'		</div>'+
							'	</div>	'+
							'</div>';
				};
				$("#teacher_f").html(html);
				$("#courseName").data("id", items._id);
				$("#courseName").text(items.name);

				// Course.items._id = items._id;
				// Course.chapterId = items.chapter[0]._id;
				// Course.knowledgeId = items.chapter[0].knowledge[0]._id;
				
				var item = items.chapter[0].knowledge[0];
				var vid = item.vid; 
				var itemTitle = item.title || "";
				var itemTitleType = itemTitle.split(".")[itemTitle.split(".").length-1];
				function playVideo(itemTitleType){
					$("#player").empty();
					if(itemTitleType == "pdf"){  //560  461
						$("#player").html('<iframe width="100%" height="560" src="'+Core.API_VER + '/pdf/' + itemTitle+'"> </iframe>');
	             		//var success = new PDFObject({ url: Core.API_VER + "/pdf/" + itemTitle }).embed("player");
					}else{ 
						// 2020-01-05
						/*var player = polyvObject('#player').videoPlayer({
						    'width':'100%',
						    'height':'560',
						    'vid' : item.vid,  //item.vid items.chapter[0].knowledge[0].vid
							'flashParams':{'allowFullScreen':'true','wmode':'window','wmode':'transparent'}
						});*/
						// 2020-01-05
						var ts = new Date().getTime();
						var sign = hex_md5("mxmCcs3emS"+item.vid+ts);
						player = null;
						player = polyvObject('#player').videoPlayer({
							'width':'98%',
							'height':'560',
							'vid' : item.vid,
							//'flashParams':{'allowFullScreen':'true','wmode':'window','wmode':'transparent'},
							'flashParams':{'allowFullScreen':'true','allowscriptaccess':'always','allowNetworking':'all','wmode':'transparent'},								
							'ts' : ts,
							'sign' : sign
						});
					}
				}
				playVideo(itemTitleType);
				
				// 添加视频列表 add
				var hList="";
				for(var i=0;i<items.chapter.length;i++){
					if(items.chapter[i].ctype == 0){

						Course.chapterId = items.chapter[i]._id;
						Course.chapterName = items.chapter[i].name;
						hList +=' <div class="list-title ellipsis">'+items.chapter[i].name+'</div><ul class="ulList none" >';
						for (var j=0;j<items.chapter[i].knowledge.length;j++) {

							var item = items.chapter[i].knowledge[j];
							var itemTitle = item.title || "";
							var itemTitleTypea = itemTitle.split(".")[itemTitle.split(".").length-1];
							
							// Course.knowledgeId = items.chapter[i].knowledge[j]._id;

							hList +=' <li class="onLi" data-vid="'+items.chapter[i].knowledge[j].vid+'" data-type="'+itemTitleTypea+'" data-id="'+items.chapter[i].knowledge[j]._id+'">'+items.chapter[i].knowledge[j].name+'</li>';	
						}
						hList +=' </ul>';
					}
					
				}
				$("#hList").html(hList);
				$("#hList div:eq(0)").addClass("bg-dateils");
				$("#hList ul:eq(0)").show();
				// $("#hList li:eq(0)").addClass("bgblack");

				// 调用右侧弹出
				$(".add_title").click(function(){
					cour_n.addLeft(newFunction());
				});
				// 点击导航
				$(".addList div").on("click",function(){
				   $(this).next(".ulList").slideToggle(300).siblings(".ulList").slideUp(500);
				   cour_n.add_(this,"bg-dateils");
				});
				$(".addList li").click(function(){
					$(this).addClass("bgblack").siblings().removeClass("bgblack");
				});
				// 右侧点击切换视频
				$(".onLi").on("click",function(){
					var vid = $(this).data("vid");
					var type = $(this).data("type");
					item.vid = vid;
					playVideo(type);
					$("#courseName").text($(this).text());
					item._id = $(this).data("id");
					Course.knowledgeId = item._id;
					Course.stuVideoCommentInitFree(item);
				});

				if($.query.get("stype") == "coursefree"){
					// console.log($(".ulList").find("li").html());
					// $(".ulList").find("li").click();
					$("#hList ul>li:first").click();	
				}
				// $(".reply").on("click",function(){
				// 	alert("A");
				// })
				
			}
		});
			//return false;
	},
	// 公开课详细相关课程
	freeXgCourses:function(_id){
		$ajax({
			url:"/course/detailCourseR",
			data:{_id : _id},
			success:function(res){
				var result = res.result;
				if(!$.isEmptyObject( result.relatedCourses )){

					if(!result.relatedCourses.teacher.photo){
						result.relatedCourses.teacher.photo = "/img/teacher.jpg"
					}else{
						result.relatedCourses.teacher.photo = "/upload/"+result.relatedCourses.teacher.photo;
					}

					var html = 	'<div class="free_news over">'+
								'	<p>相关课程</p>'+
								'	<div class="box_n addcour shadow xx_zs xiangGuanKe" data-id="'+result.relatedCourses._id+'">'+
										'<dl>'+
										'	<dt><img src="/upload/'+result.relatedCourses.photo+'"></dt>'+
										'	<dd class="fs16" style="border-bottom: 1px solid #E6E6E6;height:auto;">'+result.relatedCourses.name+'</dd>'+
										
										'	<div class="addshouke">'+
										'		<span style="width:40px;padding:0"><img src="'+result.relatedCourses.teacher.photo+'"></span>'+
										'		<span style="padding-right:15px">授课老师：'+result.relatedCourses.teacher.name+'</span>'+
										'		<span style="padding:0">学分认证：'+result.relatedCourses.credit+'学分</span>'+
										'	</div>'+
										'</dl>'+
								'	</div>'+
								'</div>';
				}
				$("#xiangGuanKe").html(html);
				$(".xiangGuanKe").on("click",function(){
					if(result.relatedCourses.fee == 0){
						window.location.href = "a_freeVideo.html?stype=course&id=" + $(this).data("id");
					}else{
						if(CurrentUser.utype == UTYPE.STUDENT){
							for (var rr = 0; rr < CurrentUser.course.length; rr++) {
								if($(this).data("id") == CurrentUser.course[rr].id){
									IndexStudent.jump();
								}else{
									window.location.href = "a_indexDetailCourseFirst.html?stype=course&id=" + $(this).data("id");
								}
							}
						}else{
							window.location.href = "a_indexDetailCourseFirst.html?stype=course&id=" + $(this).data("id");
						}
					}
				});
			}
		});
	},
	labourSubmit: function(){
		var data = Course.examItems;
		//console.log(data);
		data.isLabour = "false";
		for (var i = 0; i < data.questions.length; i ++){
			if (data.questions[i].QuestionType == EXAMTYPE.FILL || data.questions[i].QuestionType == EXAMTYPE.SUBJECTIVE){
				var thisScore = parseInt($("#" + data.questions[i].Id).next().find("input[name='score']").val());
				if ((thisScore == "" || isNaN(thisScore))&&thisScore!=0){
					data.isLabour = "true";
					continue;
				}
				data.questions[i].comment = $("#" + data.questions[i].Id).next().find("textarea[name='comment']").val();
				data.questions[i].trueOrFalse = thisScore;
				data.score += thisScore;
			}
		}
		if(data.isLabour == "true"){
			alert("还有需要阅卷的内容,请完成整个阅卷再提交");
			return;
		}
		data.courseId = data.course.id;
		data.courseName = data.course.name;
		//console.log(data);
		$ajax({
			url : "/examine/saveExamine",
			data: data,
			success: function(res){
				window.location.href = "a_examList.html";
			}
		});
	},
	stuDetailCourse: function(){
		var id = $.query.get("id");
		$ajax({
			url:"/course/detailCourse",
			data:{
				_id : id
			},
			success: function(res) {
				for(var nn=0;nn<CurrentUser.course.length;nn++){
					if(id == CurrentUser.course[nn].id && (CurrentUser.course[nn].noShowScore == true || CurrentUser.course[nn].noShowScore == 'true')){
						$(".wdcj").parent().hide();
					}
				}
				var items = res.result;
				Course.items = items;
				var chapter = items.chapter;
				$(".cont-title").text(items.name);
				Course.cname = items.name;
				window.document.title = items.name+"-课程学习-国开享学吧";
				var html = "";
				for (var i=0; i<chapter.length; ++i) {
					if(chapter[i].ctype == 1){//阶段作业
						html +='<div class="right_zj itemEvent  fw jdzy-bg" title="' + chapter[i].name + '" data-ctn="chapterCtn" data-item=\''+ JSON.stringify(chapter[i]) +'\'><span class="jdzy"></span>' + chapter[i].name + '</div>' + 
							'	<ul class="right_jd ulEvt" style="">'
					}else if(chapter[i].ctype == 2){//结业考试
						html +='<div class="right_zj itemEvent  fw jyks-bg" title="' + chapter[i].name + '" data-ctn="chapterCtn" data-item=\''+ JSON.stringify(chapter[i]) +'\'><span class="jyks"></span>' + chapter[i].name + '</div>' + 
							'	<ul class="right_jd ulEvt" style="">'
					}else {//正常章节
						html +='<div class="right_zj itemEvent" title="' + chapter[i].name + '" data-ctn="chapterCtn" data-item=\''+ JSON.stringify(chapter[i]) +'\'>' + chapter[i].name + '</div>' + 
							'	<ul class="right_jd ulEvt" style="">';
					}
                    var knowledge = chapter[i].knowledge;
                    for (var j=0; j<knowledge.length; ++j)
						html += '<li class="itemEvent" data-ctn="knowledgeCtn" data-item=\''+ JSON.stringify(knowledge[j]) +'\'>· <a href="#"> ' + knowledge[j].name + '</a></li>'
	                html += '</ul>';
				}
				$("#chapList").html(html);
				
				$(".cont_right div").on("click",function(){
                   	// $(".ulEvt").css("display","none");
                   	// $(this).next(".ulEvt").css("display","block");
                   	$(this).next(".right_jd").slideToggle(300).siblings(".right_jd").slideUp(500);
                   	$(this).addClass('zj_bg').siblings().removeClass('zj_bg');  
                   	$("#mkylaa").css("background","#f2f2f2");
                   	$(".sub-pl").show();//切换章节显示评论
                    $(".cont-zj").text($(this).data("item").name);  
                });
                $(".right_jd li").on("click",function(){
                	var i=$(".right_jd li").index(this);
                	$("#cont-main>.cont-main").eq(i).show().siblings().hide();
                	$(this).addClass("zj_bgl").siblings().removeClass("zj_bgl");
					$(".cont-zj").text($(this).data("item").name);

                	$("#mkylaa").css("background","#f2f2f2");
                  	$(".sub-pl").show();//切换章节显示评论
                	$(".main-title>span:first").addClass('bg1').siblings().removeClass('bg1');
					$(".mian-vido:first").show().siblings().hide();
                });
                $("#chapList").on("click", ".itemEvent", function(){
					Course.knowledgeId = $(this).data("item")._id;
					Course.kname = $(this).data("item").name;
					$("#player").empty();
					var ctn = $(this).data("ctn");
					var item = $(this).data("item");
					var pro = $.query.get('pro');
					SetLS("currentItem",item);		
					if (ctn == "chapterCtn") {
						SetLS("isChaper","true");
						Course.chapterId = item._id;
						Course.chname = item.name;
						if (item.ctype == 1) { //阶段作业
							$(".main-title,.sub-pl").addClass("hide");
							$(".mian-vido:last").show().siblings().hide();
							if(pro == '1' || pro == 1){//学历课程 做题次数限制处理
								$ajax({
									url: '/examine/getStuOneJobCHs',
									data: {
										id: CurrentUser._id,
										cid: $.query.get('id'),
										chid: item._id,
										etype: item.ctype
									},
									success: function(res){
										if(res.result.count < 3){
											prohome();
										}else{
											alert('您的做题次数已经用完！');	
											window.location.href = 'a_s_courseLearning.html?id='+$.query.get('id')+"&pro="+$.query.get('pro');
										}
									}
								})
														
							}else
								prohome();//非学历课程 默认调用
							function prohome(){
								//原有
								//Course.examInit(item.exam, $("#issue"));
								// tkzq
								$ajax({
									url: '/question/getQuestions',
									data: {
										cid: id,
										etype: item.ctype,
										chapterId: item._id
									},
									success: function(res){
										Course.examInit(res.result, $("#issue"));
									}
								});
							}
						} else if (item.ctype == 2) { //结业考试
							var examName = $(this).text();
							if(pro == '1' || pro == 1){//学历课程 做题次数限制处理
								$ajax({
									url: '/examine/getStuOneJobCHs',
									data: {
										id: CurrentUser._id,
										cid: $.query.get('id'),
										chid: item._id,
										etype: item.ctype
									},
									success: function(res){
										if(res.result.count < 3){
											proexam(examName);
											$(".main-title,.sub-pl").addClass("hide");
											$(".mian-vido:last").show().siblings().hide();
										}else{
											alert('您的做题次数已经用完！');	
											window.location.href = 'a_s_courseLearning.html?id='+$.query.get('id')+"&pro="+$.query.get('pro');
										}
									}
								});
															
							}else{
								proexam(examName);//非学历课程 默认调用
								$(".main-title,.sub-pl").addClass("hide");
								$(".mian-vido:last").show().siblings().hide();
							}
							function proexam(examName){
								//tkzq
								Course.examFirst( items.name, item.extra, $("#issue"),examName,item._id);
								//原有
								//Course.examFirst( items.name, item.extra, $("#issue"),examName,item._id);

								//Course.examInit("http://examapi.netmall.net.cn/exam/GetExamQuestionsByKP?kpname="+ items.name +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4&QuestionInfo="+item.extra, $("#issue"));

							}
							
						} else {
							$(".main-title,.sub-pl").removeClass("hide");
							$(".main-title>span:first").addClass('bg1').siblings().removeClass('bg1');
							$(".mian-vido:first").show().siblings().hide();
							$(this).next("ul").find("li:first").click();
						}
					} else if (ctn == "knowledgeCtn") {
						var vid='';
						var knowledgeName='';
						if(Course.knowClick){
							vid=$.query.get("vid");
							knowledgeName=$.query.get("knowledgeName");
							Course.knowClick = false;
						}
						if(vid){
							if(vid === "undefined"){
								alert("此节还没有视频！");
							}else{
								item.vid = vid;
							}
							$(".cont-zj").text(knowledgeName);  
						}
						SetLS("isChaper","false");
						var itemTitle = item.title || "";
						var itemTitleType = itemTitle.split(".")[itemTitle.split(".").length-1];
						if(itemTitleType == "pdf"){
							var h = '<iframe width="100%" height="461" src="'+Core.API_VER + '/pdf/' + itemTitle+'" id="Pcyear"> </iframe>';
							$("#player").html(h);
							$("#pdfmask").removeClass('hide');
						}else{ 
							$("#pdfmask").addClass('hide');
							// 2019-11-20
							var ts = new Date().getTime();
							var sign = hex_md5("mxmCcs3emS"+item.vid+ts);
							var player = polyvObject('#player').videoPlayer({
							    'width':'100%',
							    'height':'461',
							    'vid' : item.vid,
								'flashParams':{'allowFullScreen':'true','allowscriptaccess':'always','allowNetworking':'all','wmode':'transparent'},
								'ts' : ts,
								'sign' : sign
							});
						}
						//评论答疑 初始化
						Course.stuVideoCommentInit(item);
						//原有
						//Course.examInit(item.exam, $("#issue"));

						//题库自取 修改
						$ajax({
							url:'/question/getQuestions',
							data: {
								cid: $.query.get('id'),
								etype: 0,
								utype: CurrentUser.utype,
								chapterId: $(this).parent().prev().data('item')._id,
								knowledgeId: item._id
							},
							success: function(res){
								Course.examInit(res.result, $("#issue"));	
							}
						});
						
						var studyData = {};
						studyData.cid = Course.items._id;
						studyData.chid = Course.chapterId;
						studyData.kid = Course.knowledgeId;
						studyData.field = "video";
						SetLS("studyData",studyData);	
						$ajax({
							url:"/course/study",
							data:studyData,
							success: function(res){
							}
						});		
					}
					return false;
				});
				//初始化页面 选中第一个
				if($.query.get("chaptervid")===0 && $.query.get("knowledgevid")===0){
					$("#chapList div:first").click();
					$("#chapList li:first").click();
				}else if($.query.get("ifExam")){
					var chaptervid = $.query.get("chaptervid");
					$("#chapList div:eq(" + chaptervid +")").click();
				}else{
					Course.chapterId = $.query.get('chapterid');
					var chaptervid = $.query.get("chaptervid");
					var knowledgevid = $.query.get("knowledgevid");
					if(knowledgevid <= 0)
						knowledgevid = 0;
					if(chaptervid > 0){
						$("#chapList div:eq(" + chaptervid +")").addClass('zj_bg');
						$("#chapList div:eq(" + chaptervid +")").next("ul").show();
						$("#cont-main>.cont-main").eq(knowledgevid).show();
						$("#chapList li:eq(" + knowledgevid +")").addClass('zj_bgl');
						$("#chapList div:eq(" + chaptervid +")").next("ul").find("li:eq(" + knowledgevid +")").click();
					}else{
						if(knowledgevid > 0){
							$("#chapList div:first").addClass('zj_bg');
							$("#chapList div:eq(" + chaptervid +")").next("ul").show();
							$("#cont-main>.cont-main").eq(knowledgevid).show();
							$("#chapList li:eq(" + knowledgevid +")").click();
						}else{
							$("#chapList div:first").click();
						}
					}
				}
				// add 记录功能 2016年3月3日11:37:36
				$ajax({
					url:"users/updateLastCourse",
					data:{
						id : CurrentUser._id,
						lastCourseId : res.result._id,
						lastCourseName : res.result.name,
					},
					success:function(resa){
						console.log("访问成功！");
					}
				})
				// 重置browser缓存
				if(!CurrentUser.features.lastCourse)
					CurrentUser.features.lastCourse = {};
				CurrentUser.features.lastCourse.id = $.query.get("id");
				CurrentUser.features.lastCourse.name = res.result.name;
				SetLS("user",CurrentUser)
				// end
			}
		});
	},
	
	examFirst: function(courseName,extra, $dom,examName,homeId){
		var examNum = 0;
		var examNumArray = extra.split('|');
		for (var i = examNumArray.length - 1; i >= 0; i--) {
			examNum += parseInt(examNumArray[i].split(',')[1]); 
		};
		var html = "";
			html += '<div class="cont-main kqxz-main">' +
					'<div class="kqxz-cont">' +
					'<div class="kqxz-title">考前须知</div> ' +
					'<div class="kqxz-js marB">' +
					'<p>1、请您在学习完全部课程后开始考试；</p>' +
					'<p>2、结业考试可以多次参加，最终成绩采用最高分计算；</p>'	+
					'<p>3、当试卷中存在主观题时，提交后系统将分配给老师判卷；</p>'	+
					'<p>4、考试结束后，请在10个工作日之后到考试记录里面查看成绩。</p>' +
					'</div>' +
					'<div class="kqxz-stsl" style = "padding-top:30px">'+
					'<span class="left">试题数量： <i>'+ examNum +'</i> 道</span>' +
					'<span class="right">参考时间：<i>120</i>分钟</span>' +	
					'</div>' +
					'<div class="kqxz-sub">' +
					'<div class=" sub" id = "sub">开始考试</div></div></div>';
									
			$dom.html(html);
			$("#sub").click(function(){
				//Course.examInit("http://ksapi.lndx.edu.cn/exam/GetExamQuestionByKPAndConditions?kpname="+ courseName +"&AccessToken=17f15623-2d37-4f4e-b034-a46c669ff7f4&QuestionInfo="+extra, $dom);	
				// 原有
				// var exam = new Object();
				// exam.courseName = courseName;
				// exam.extra = extra;
				// exam.examName = examName;
				// exam.examNum = examNum;
				// exam.courseId = $.query.get('id');
				// exam.homeworkId = homeId;
				// exam.pro = $.query.get('pro');
				// SetLS('exam',exam);
				// window.location.href = '/finalTest.html?id='+$.query.get('id')+'&pro='+$.query.get('pro');

				//tkzq
				$ajax({
					url: '/question/getQuestions',
					data: {
						cid: $.query.get('id'),
						etype: 2,
						chapterId: homeId,
						extra: extra
					},
					success: function(res){
						var exam = new Object();
						exam.courseName = courseName;
						exam.examName = examName;
						exam.examNum = examNum;
						exam.courseId = $.query.get('id');
						exam.homeworkId = homeId;
						exam.questions = res.result;
						exam.pro = $.query.get('pro');
						SetLS('exam',exam);
						window.location.href = '/finalTest.html';
					}
				});
			});	
	},
	stuPercentInit: function(){
		var id = $.query.get("id");
		var pro = $.query.get('pro');
		// var md5 = $.query.get('md5');
		// if(md5 != undefined)
		// 	var pwd = md5;
		// else 
		// 	var pwd = CurrentUser.password;
		// $ajax({
		// 	url:"/users/lgn",
		// 	data:{email:CurrentUser.email, pwd:pwd},
		// 	success: function(res) {
		// 		SetLS("user", res.result[0]);
		// 		CurrentUser = res.result[0];
		// 		var course = new Array();
		// 		for (var i = 0; i < CurrentUser.course.length; i ++){
		// 			if (id == CurrentUser.course[i].id){
		// 				course[0] = new Object();
		// 				course[0] = CurrentUser.course[i];
 	// 				}
 	// 				if(id == CurrentUser.course[i].id && (CurrentUser.course[i].noShowScore == true || CurrentUser.course[i].noShowScore == 'true')){
		// 				$(".wdcj").parent().hide();
		// 			}
 	// 			}
					
		// 	}
		// });
		$ajax({
			url : "/examine/getExamByStu",
			data: {
				cid: id,
				stuId: CurrentUser._id,
				isLabour: "all"
			},
			success: function(res){
				var p_exam = 0;
				if(res.result.score)
					p_exam = 1;
				$ajax({
					url: "/users/courseRealtimeStatus",
	        		data: {
	        			userId: CurrentUser._id,
						courseId: id
	        		},
					success: function(res){
						if(CurrentUser.features.registerType == 2)
							$(".wdcj").parent().hide();
						var data = res.result;
						//console.log(data);
						if(data.proportion.video ==0 ||data.proportion.video == undefined){
							$("#videoShow").hide();
						}
						if(data.proportion.practice ==0 || data.proportion.practice == undefined){
							$("#practiceShow").hide();
						}
						if(data.proportion.talk ==0 || data.proportion.talk == undefined){
							$("#talkShow").hide();
						}
						if(data.proportion.homework ==0 || data.proportion.homework == undefined){
							$("#homewordShow").hide();
						}
						if(data.proportion.exam ==0 || data.proportion.exam == undefined){
							$("#examShow").hide();
						}
						if(data.proportion.tutor ==0 || data.proportion.tutor == undefined){
							$("#tutorShow").hide();
						}
						var proportion = parseInt(data.progress);
						var p_practice = parseInt(data.rate.practice);
						var p_talk = parseInt(data.rate.talk);
						var p_video = parseInt(data.rate.video);
						var p_homework =  parseInt(data.rate.homework);
						var p_exam = parseInt(data.rate.exam);
						window.document.title = data.name+"-课程进度-国开享学吧";
						$(".cont-title").text(data.name);
						var course = "";
						for (var i = 0; i < 1; i ++){
							var pobj = {proportion:{name:"proportion",text:"总进度",percent:proportion},
										p_practice:{name:"p_practice",text:"每课一练",percent:p_practice},
										p_talk:{name:"p_talk",text:"评论",percent:p_talk},
										p_video:{name:"p_video",text:"微课学习 ",percent:p_video},
										p_homework:{tname:"p_homework",text:"阶段作业",percent:p_homework},
										p_exam:{tname:"p_exam",text:"结业考试",percent:p_exam}};
							
							for (var key in pobj){
								var percent = pobj[key].percent.toFixed(2);
								if(percent > 100)
									percent = 100;
								var bfb =parseInt(percent) + '%';
								//$("#" + key).text("sdasdasdas");
								$("#" + key).attr("data-text", bfb);
								$("#" + key).attr("data-percent", percent);
								// $("#" + key).find(".last").text(pobj[key].text + " : " + percent + "%");
							}
							$('.myStat1').circliful();
							$('.myStat2').circliful();
							$('.myStat3').circliful();
							$('.myStat4').circliful();
							$('.myStat5').circliful();
							$('.myStat6').circliful();

							// //知识点进度 wy add
							var id = $.query.get("id");
							$ajax({
								url:"/users/courseChapterRate",
								data:{
									userId: CurrentUser._id,
									courseId: id
								},
								success: function(res) {
									var items = res.result;
									//alert(items.chapter[0].knowledge[0]._id);
									Course.items = items;
									var chapter = items.chapter;
									var idlength = 0;
									//console.log(items);
									var html = "";
									for (var i=0; i<items.length; ++i) {
										if(items[i].ctype != 0) {
											//类型1：作业；2：考试
											html += '<div class="kcjd-zw-ml itemEvent"><a style="color:#666666" href="a_s_courseLearning.html?id='+ id +'&chaptervid='+ i +'&ifExam=true&pro='+ $.query.get('pro') +'"> ' + items[i].name + '</a></div>'
										}else{
											//类型0 章节
											html += '<div class="kcjd-zw-ml itemEvent fang" title="' + items[i].name + '" data-ctn="chapterCtn" >' + items[i].name + '</div>' + 
												'	<ul class="kcjd-zw-xj ulEvt" style="display:none">'
					                    }
					                    var knowledge = items[i].knowledge;
					                    if(items[i].ctype == 0){
						                    for (var j=0; j<knowledge.length; ++j){
							     				if(knowledge[j].status ==2){
							     					html += '<li class="itemEvent" data-ctn="knowledgeCtn" ><span class="blu">已完成</span><i class="xt-3"></i><a style="color:#666666" href="a_s_courseLearning.html?id='+ id +'&chapterid='+ items[i].id +'&chaptervid='+ i +'&knowledgevid='+ j +'&knowledgeName='+ knowledge[j].name +'&vid='+ items[i].knowledge[j].vid +'&pro='+ pro +'"> ' + knowledge[j].name + '</a></li>'      
							     				}else if(knowledge[j].status ==1){
							     					html += '<li class="itemEvent" data-ctn="knowledgeCtn" ><span class="org">学习中</span><i class="xt-2"></i><a style="color:#666666" href="a_s_courseLearning.html?id='+ id +'&chapterid='+ items[i].id +'&chaptervid='+ i +'&knowledgevid='+ j +'&knowledgeName='+ knowledge[j].name +'&vid='+ items[i].knowledge[j].vid +'&pro='+ pro +'"> ' + knowledge[j].name + '</a></li>'
							     				}else{
							     					html += '<li class="itemEvent" data-ctn="knowledgeCtn" ><span >未开始</span><i class="xt-1"></i><a style="color:#666666" href="a_s_courseLearning.html?id='+ id +'&chapterid='+ items[i].id +'&chaptervid='+ i +'&knowledgevid='+ j +'&knowledgeName='+ knowledge[j].name +'&vid='+ items[i].knowledge[j].vid +'&pro='+ pro +'"> ' + knowledge[j].name + '</a></li>'
							     				}
							                }
						                }
						                	html += '</ul>';
									}
									$("#chapList").html(html);

									$(".kcjd-zw-ml").on("click",function(){
										$(this).toggleClass("shou").siblings(".kcjd-zw-ml").removeClass("shou");
									})
									
									$(".kcjd-zw div").on("click",function(){

					                   	$(this).next(".kcjd-zw-xj").slideToggle(300).siblings(".kcjd-zw-xj").slideUp(500);
					                   	$(this).addClass('zj_bg').siblings().removeClass('zj_bg');  
					                   	$("#mkylaa").css("background","#f2f2f2");
					                   	//$(".sub-pl").show();//切换章节显示评论
					                   	//$(".cont-zj").text($(this).data("item").name);  
					                });
					              
									}
								});
						}
						Course.knowClick = true;
					}
				});
			}
		});
	},
	scoreView: function(){
		var CurrentUser = GetLS("user");
		var _id = $.query.get("id");
    	$ajax({
    		url: '/users/courseRealtimeStatus',
    		data: {
    			userId: CurrentUser._id,
    			courseId: _id
    		},
    		success: function(res){
				var course = res.result;
				$("#courseName").data("id", _id);
				$("#courseName").text(course.name);
				window.document.title = course.name+"-我的成绩-国开享学吧";
				var knowledgePercent = course.score.practice;
				var talkPercent = course.score.talk;
				var videoPercent = course.score.video;
				var homeworkPercent = course.score.homework;
				var sumScore = course.sumScore;
				var sumScoreShow = "否";
				if(sumScore >= 60){
					sumScoreShow = "是";
					$('#scoreimg').addClass('he_png');
					$('#scoreimg').html('<img src="../img/wd_w2.png">');
				} else {
					$('#scoreimg').addClass('bhe_png');
					$('#scoreimg').html('<img src="../img/wd_w1.png">');
					
				}
				
				var html = '';
				html += '' +
	              '  <tr class="tab-bg">' +
	              '      <td></td>' +
	              '      <td>成绩</td>' +
	              '      <td>权重</td>' +
	              '      <td>总成绩</td>' +
	              '      <td>是否合格</td>' +
	              '  </tr>';
	              var sumScoreAndShow = '<td rowspan="6" style="font-size:30px">' + ((sumScore)==0?"0":sumScore) + '</td>' +
                  						'<td rowspan="6" style="font-size:30px">' + sumScoreShow + '</td>';
					var sumScoreAndShowFlag = true;
				if(course.proportion.video > 0) {
				     html += '<tr>' +
                  '<td> 微课学习 </td>' +
                  '<td>' + videoPercent + '</td>' +
                  '<td>' + course.proportion.video + '%</td>' ;
                  if(sumScoreAndShowFlag)
                  	 html += sumScoreAndShow;
                     sumScoreAndShowFlag = false;
              	     html += '</tr>';
				}
				if(course.proportion.practice > 0) {
					html += '<tr>' +
		              '    <td> 每课一练 </td>' +
		              '    <td>' + knowledgePercent + '</td>' +
		              '    <td>' + course.proportion.practice + '%</td>';
		            if(sumScoreAndShowFlag)
                  	 html += sumScoreAndShow;
                     sumScoreAndShowFlag = false;
              	     html += '</tr>';
		    	}
				if(course.proportion.talk > 0) {
					html += '<tr>' +
		              '    <td> 评论 </td>' +
		              '    <td>' + talkPercent + '</td>' +
		              '    <td>' + course.proportion.talk + '%</td>';
		             if(sumScoreAndShowFlag)
                  	html += sumScoreAndShow;
                    sumScoreAndShowFlag = false;
              		html += '</tr>';
				}
				if(course.proportion.homework > 0) {
					html += '<tr>' +
		              '    <td> 阶段作业 </td>' +
		              '    <td>' + homeworkPercent + '</td>' +
		              '    <td>' + course.proportion.homework + '%</td>';
		             if(sumScoreAndShowFlag)
                  	html += sumScoreAndShow;
                  	sumScoreAndShowFlag = false;
              	html += '</tr>';
				}
   				
				if(course.proportion.exam > 0) {
					html += '<tr>' +
		              '    <td> 结业考试(理论)</td>' +
		              '    <td>' + (typeof(res.result.score)=='undefined'?"暂无成绩":course.score.exam) + '</td>' +
		              '    <td>' + course.proportion.exam + '%</td>' ;
		              if(sumScoreAndShowFlag)
                  	html += sumScoreAndShow;
                  	sumScoreAndShowFlag = false;
              	html += '</tr>';
				}
				if(typeof(course.proportion.tutor)!='undefined' && course.proportion.tutor > 0) {
					html += '<tr>' +
		              '    <td> 结业考试(实战)</td>' +
		              '    <td>' + (typeof(course.score.tutor)=='undefined'?"暂未评分":course.score.tutor) + '</td>' +
		              '    <td>' + (typeof(course.proportion.tutor)=='undefined'?0:course.proportion.tutor) + '%</td>';
		              if(sumScoreAndShowFlag)
                  	html += sumScoreAndShow;
                  	sumScoreAndShowFlag = false;
              	html += '</tr>';
				}
				html += '';
				//////
				$("#sumScoreShow").html(html);
			
    		}
    	})
	},
	stuVideoCommentInit: function(item){
		if (CurrentUser.utype == UTYPE.TUTOR){
			$("#quesCreate").css("display","none");
		}
		// 评论
		$ajax({
			url: "/comment/list",
			data: {
				kid: item._id
			},
			success: function(res){
				var data = res.result.results;
				var html = "";
				for (var i = 0; i < data.length;i ++){
					var photo = 'upload/' + data[i].ownerPhoto;    
					if(!data[i].ownerPhoto){
						photo = 'img/teacher.jpg';
					}
					html += Course.gnCommentContent(data[i]._id,data[i].content,data[i].ownerName,data[i].create,photo);
				}
				$("#newsList").html(html);
			}
		});
		var data = new Object();
		data.to = (typeof(Course.items.tutors[0])=="undefined"?"meiyoufudaoloshibunengshanchupinglun":Course.items.tutors[0]._id);
		data.knowledge = Course.knowledgeId;
		data.cid = $.query.get("id");
		// 答疑
		$ajax({
			url: "/message/list",
			data: data,
			success: function(res){

				var data = res.result;
				var html = '<div id="quesList" style="max-height: 300px;overflow: auto;">';
				for(var i = 0; i < data.length; i ++){
					$("#fromName").text(data[i].toName);
					var qual = true;
					var stacss = '';
					var appraise = ['','很不满意','不满意','一般','满意','非常满意'];
					var statext = '请对本次答疑打分：';
					if(data[i].hasOwnProperty('star') && data[i].star != 0){
						for(var s=0; s<data[i].star;s++){
							stacss += '<li class="cur"></li>';
						}
						for(var f=0; f<(5-data[i].star); f++){
							stacss += '<li></li>';
						}
					}else{
						for(var f=0; f<5; f++){
							stacss += '<li></li>';
						}
					}
					var ratehtml = '<div class="pal10 heartWrap" style="overflow:right;">'+
	                               '	<p class="float_l fs14 c9">'+ statext +'</p>'+	
	                               '	<ul class="heart-grade js_herat_add">'+	
	                               stacss+
	                               '	</ul>'+
	                               '	<div class="heart-submit rel">'+
	                               '		<span class="fs14 c9">'+ appraise[data[i].star] +'</span>'+
	                               '		<button data-id="'+ data[i]._id +'" class="fs14 btn-danger btn_wid bg_red rateSub">提交</button>'+
	                               '	</div>'+	
	                               '</div>';
					var d = Id2url(data[i].fromUrl,"photo");
					if (CurrentUser._id == data[i].from)
						d = Id2url(CurrentUser);
					else if(d == undefined || d == '/upload/undefined')
						d="img/tou2.jpg";
	
					html += '<div class="clearb">' + 
                            '    <div class="float_r" style="width:10%;padding:1em;">' + 
                            '		<img src="' + d + '" style="width:3em;height:3em;">' + 
                            '	 </div>' + 
                            '    <div class="demo clearfix fr float_r" style="width:85%;">' + 
                            '        <span class="triangle right" ></span>' + 
                            '        <div class="article">' + data[i].content + '</div>' + 
                            '    </div>' + 
                            '    <div class="float_r tx-c" style="padding: 0 1em;font-size:0.8em;clear: both;">'+
                            '		<span class="float_r" style="padding:0 10px;color:#750B0D;">'+data[i].fromName +'</span>'+ (new Date(data[i].create)).pattern("yyyy-MM-dd HH:mm:ss") + 
                            '	</div>' + 
                            '</div>';
                    if(data[i].hasOwnProperty('answer')){
                    	html += '<div class="clearb">' + 
	                            '    <div class="float_l" style="width:10%;padding:1em;">' + 
	                            '		<img src="' + d + '" style="width:3em;height:3em;">' + 
	                            '	 </div>' + 
	                            '    <div class="demo clearfix float_l" style="width:85%;">' + 
	                            '        <span class="triangle " ></span>' + 
	                            '        <div class="article">' + data[i].answer + '</div>' + 
	                            '    </div>' + 
	                            '    <div class="float_l tx-c" style="padding: 0 1em;font-size:0.8em;clear: both;">'+
	                            '		<span class="float_l" style="padding:0 10px;color:#750B0D;">'+data[i].toName +'</span>'+ (new Date(data[i].answTime)).pattern("yyyy-MM-dd HH:mm:ss") + 
	                            '	</div>' + 
	                            	ratehtml+
	                            '</div>';
                    }
				}
				html += '</div>';
				$("#ques").html(html);
				var obj = document.getElementById("quesList"); 
				obj.scrollTop=obj.scrollHeight; 
				//答疑评分
				$(".js_herat_add>li").mouseenter(function(){
			        appraiseHeartAdd(this);
			    });
				$('.rateSub').click(function(){
					var staNum = 0;
					var id = $(this).data('id');
					var ul = $(this).parent().prev('ul').children();
					ul.each(function(item){
						if( $(this).attr('class') == 'cur' ){
							staNum += 1
						}
							
					});
					$ajax({
						url: '/message/setStar',
						data: {
							id: id,
							star: staNum
						},
						success: function(res){
							$(".rateSub").addClass('hidden');
							$(".js_show").removeClass('hidden');
							setTimeout(function(){
						        $(".js_show").hide();
						    },2000);
						}
					});
					
				})
			}
		});
		// add 制空
		$("#messContent,#commentContent").val("");
		$("#messnumtext").text("0/200");
		// end
		var tutors = "";
		for (var i = 0; i < Course.items.tutors.length; i ++){
			var checked = "";
			if(i == 0)
				checked = "checked";
			tutors +=  	'<li style="padding:3px 0;"> ' + 
                        '    <span style="margin-right:5px;"><input type="radio" ' + checked + ' name="teaName" data-to="' + Course.items.tutors[i]._id + '"></span>' + 
                        '    <span>' + Course.items.tutors[i].name + '</span>' + 
                        '</li> ';
		}
		$("#sendlist").html(tutors);
	},
	stuMessageSend: function(){
		if (CurrentUser.utype == UTYPE.VISITOR)
			return alert("您没有提问题的权限");
		if($("#messContent").val().length == 0)
			return alert("答疑不能为空");
		var data = new Object();
		data.content = $("#messContent").val();
		data.media = 0;
		data.cid = Course.items._id,
		data.clname = CurrentUser.Class,
		data.chid = Course.chapterId;
		data.knowledge = Course.knowledgeId;
		data.cname = $(".cont-title").text();
		data.kname = Course.kname;
		data.chname = Course.chname;
		data.type = 0;
		data.to = Course.items.tutors[0]._id;
		$ajax({
			url: '/grade/findStudentGrade',
			data: {
				studentId: CurrentUser._id,
				courseId: Course.items._id
			},
			success: function(res){
				data.gradeId = res.result._id ;//'5652a0011cd582f82be9a0d6';班级test ID 用于测试
				data.gradeName = res.result.name;//'班级test';
				$ajax({
					url: "/message/add",
					data: data,
					success: function(res){
						// ClearLS("plAnddy");
						var html  = '<div class="clearb">' + 
		                            '    <div class="float_r" style="width:10%;padding:1em;"><img src="' + (Id2url(CurrentUser) == undefined?'img/tou2.jpg':Id2url(CurrentUser)) + '" style="width:3em;height:3em;"></div>' + 
		                            '    <div class="demo clearfix fr float_r" style="width:85%;">' + 
		                            '        <span class="triangle right"></span>' + 
		                            '        <div class="article">' + res.result.content + '</div>' + 
		                            '    </div>' + 
		                            '    <div class="float_r tx-c" style="padding: 0 1em;font-size:0.8em;clear: both;"><span style="padding:0 10px;color:#750B0D;float:right;">'+CurrentUser.name+'</span>' + (new Date(res.result.create)).pattern("yyyy-MM-dd HH:mm:ss") + '</div>' + 
		                            '</div>';
						$("#quesList").append(html);
						
						$("#messContent").val("");
						$("#messnumtext").text("0/200");
						var obj = document.getElementById("quesList"); 
						obj.scrollTop=obj.scrollHeight;
					}
				});
			}
		});	
	},
	mobileStudy: function(){
		var code = $.query.get("code");
		if(code){
			$ajax({
				url:"/course/detailCourseM",
				data:{
					code : code
				},
				success: function(res) {
					var items = res.result;
				    Course.items = items;
					$("#courseName").data("id", items._id);
					$("#courseName").text(items.name);
					var item = items.chapter[0].knowledge[0];
					var vid = item.vid; 
					var itemTitle = item.title || "";
					var itemTitleType = itemTitle.split(".")[itemTitle.split(".").length-1];
					function playVideo(itemTitleType){
						if(itemTitleType == "pdf"){
							$("#player").html('<iframe width="100%" height="560" src="'+Core.API_VER + '/pdf/' + itemTitle+'"> </iframe>');
						}else{ 
							var player = polyvObject('#player').videoPlayer({
							    'width':'100%',
							    'height':'560',
							    'vid' : item.vid,
								'flashParams':{'allowFullScreen':'true','wmode':'window','wmode':'transparent'}
							});
						}
					}
					playVideo(itemTitleType);
					
					// 添加视频列表 add
					var hList="";
					for(var i=0;i<items.chapter.length;i++){
						if(items.chapter[i].ctype == 0){

							Course.chapterId = items.chapter[i]._id;
							Course.chapterName = items.chapter[i].name;
							hList +=' <div class="list-title ellipsis">'+items.chapter[i].name+'</div><ul class="ulList none" >';
							for (var j=0;j<items.chapter[i].knowledge.length;j++) {
								var item = items.chapter[i].knowledge[j];
								var itemTitle = item.title || "";
								var itemTitleTypea = itemTitle.split(".")[itemTitle.split(".").length-1];
								hList +=' <li class="onLi" data-vid="'+items.chapter[i].knowledge[j].vid+'" data-type="'+itemTitleTypea+'" data-id="'+items.chapter[i].knowledge[j]._id+'">'+items.chapter[i].knowledge[j].name+'</li>';	
							}
							hList +=' </ul>';
						}
						
					}
					$("#hList").html(hList);
					$("#hList div:eq(0)").addClass("bg-dateils");
					$("#hList ul:eq(0)").show();

					// 调用右侧弹出
					$(".add_title").click(function(){
						cour_n.addLeft(".video-list");
					});
					// 点击导航
					$(".addList div").on("click",function(){
					   $(this).next(".ulList").slideToggle(300).siblings(".ulList").slideUp(500);
					   cour_n.add_(this,"bg-dateils");
					});
					$(".addList li").click(function(){
						$(this).addClass("bgblack").siblings().removeClass("bgblack");
					});
					// 右侧点击切换视频
					$(".onLi").on("click",function(){
						var vid = $(this).data("vid");
						var type = $(this).data("type");
						item.vid = vid;
						playVideo(type);
						$("#courseName").text($(this).text());
						item._id = $(this).data("id");
						Course.knowledgeId = item._id;
						Course.stuVideoCommentInitFree(item);
					});

					if($.query.get("stype") == "coursefree"){
						$("#hList ul>li:first").click();	
					}
					
				}
			});
		}else
			console.log('code 不存在！');
	}
}


function newFunction() {
	return ".video-list";
}
//每日一练，视频，答疑，评论
